<commit_before><?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCityTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('city', function (Blueprint $table) {
            $table->increments('id');

            // Name in URL, lower-case. e.g. "helsinki", "beijing"
            $table->string('slug', 50);

            // Country id
            $table->integer('country_id')->unsigned()->nullable();

            // Icon/cover image
            $table->integer('image_id')->unsigned()->nullable();

            // Timezone, like "Europe/Helsinki", "Asia/Shanghai"
            $table->string('timezone', 30);

            // Timestamps
            $table->timestamps();
            $table->softDeletes();

            // Unique
            $table->unique(['country_id', 'slug']);

            // Foreign keys
            $table->foreign('country_id')->references('id')->on('country')->onDelete('set null');
            $table->foreign('image_id')->references('id')->on('image')->onDelete('set null');
        });

        // MySQL/MariaDB GEOMETRY, which is not supported by Laravel Blueprint
        DB::statement('ALTER TABLE city ADD coordinate POINT AFTER image_id');

        Schema::create('city_translation', function (Blueprint $table) {
            $table->increments('id');

            // Parent
            $table->integer('city_id')->unsigned();

            // ISO 639-1 codes (2 letters)
            $table->string('locale', 2);

            // Name
            $table->string('name')->nullable();

            // Page content
            $table->text('content')->nullable();

            // Timestamps
            $table->timestamps();

            // Unique
            $table->unique(['city_id','locale']);

            // Foreign key
            $table->foreign('city_id')->references('id')->on('city')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('city_translation');

        Schema::drop('city');
    }
}<commit_msg>Comment city table.<commit_after><?php

/*
 * This file is part of santakani.com
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * CreateCityTable
 *
 * Database migration to create "city" and "city_translation" table.
 *
 * @author <NAME> <<EMAIL>>
 * @see https://github.com/santakani/santakani.com/wiki/City
 */
class CreateCityTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('city', function (Blueprint $table) {
            $table->increments('id');

            $table->string('slug');
            $table->integer('country_id')->unsigned()->nullable();
            $table->integer('image_id')->unsigned()->nullable();
            $table->string('timezone'); // "Europe/Helsinki", "Asia/Shanghai"

            $table->timestamps();
            $table->softDeletes();

            $table->unique(['country_id', 'slug']);

            $table->foreign('country_id')->references('id')->on('country')->onDelete('set null');
            $table->foreign('image_id')->references('id')->on('image')->onDelete('set null');
        });

        // MySQL/MariaDB GEOMETRY, which is not supported by Laravel Blueprint
        DB::statement('ALTER TABLE city ADD coordinate POINT AFTER image_id');

        Schema::create('city_translation', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('city_id')->unsigned();
            $table->string('locale', 2); // ISO 639-1 (2 letters)

            $table->string('name')->nullable();
            $table->text('content')->nullable(); // HTML

            $table->timestamps();

            $table->unique(['city_id','locale']);

            $table->foreign('city_id')->references('id')->on('city')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('city_translation');

        Schema::drop('city');
    }
}
{'fraction_non_alphanumeric': 0.1742560865644725, 'fraction_numerical': 0.0036068530207394047, 'mean_word_length': 2.196685878962536, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 77, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1369871', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1214, 'n_words': 233}