mirror of
https://github.com/flarum/framework.git
synced 2025-02-02 12:05:33 +08:00
Use the new migration shortcuts in most of core's migrations
This commit is contained in:
parent
14042bedaf
commit
9c7523e3b1
|
@ -8,20 +8,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('access_tokens', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'access_tokens',
|
||||
function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->timestamp('created_at');
|
||||
$table->timestamp('expires_at');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('access_tokens');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,17 +8,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('api_keys', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'api_keys',
|
||||
function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('api_keys');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,18 +8,13 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('config', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'config',
|
||||
function (Blueprint $table) {
|
||||
$table->string('key', 100)->primary();
|
||||
$table->binary('value')->nullable();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('config');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('discussions', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'discussions',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('title', 200);
|
||||
$table->integer('comments_count')->unsigned()->default(0);
|
||||
|
@ -28,10 +28,5 @@ return [
|
|||
$table->integer('last_user_id')->unsigned()->nullable();
|
||||
$table->integer('last_post_id')->unsigned()->nullable();
|
||||
$table->integer('last_post_number')->unsigned()->nullable();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('discussions');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,20 +8,15 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('email_tokens', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'email_tokens',
|
||||
function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('email', 150);
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->timestamp('created_at');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('email_tokens');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,21 +8,16 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('groups', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'groups',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name_singular', 100);
|
||||
$table->string('name_plural', 100);
|
||||
$table->string('color', 20)->nullable();
|
||||
$table->string('icon', 100)->nullable();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('groups');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('notifications', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'notifications',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('sender_id')->unsigned()->nullable();
|
||||
|
@ -24,10 +24,5 @@ return [
|
|||
$table->dateTime('time');
|
||||
$table->boolean('is_read')->default(0);
|
||||
$table->boolean('is_deleted')->default(0);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('notifications');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,19 +8,14 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('password_tokens', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'password_tokens',
|
||||
function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->timestamp('created_at');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('password_tokens');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,19 +8,14 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('permissions', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'permissions',
|
||||
function (Blueprint $table) {
|
||||
$table->integer('group_id')->unsigned();
|
||||
$table->string('permission', 100);
|
||||
$table->primary(['group_id', 'permission']);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('permissions');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
// We need a full custom migration here, because we need to add the fulltext
|
||||
// index for the content with a raw SQL statement after creating the table.
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('posts', function (Blueprint $table) {
|
||||
|
|
|
@ -8,21 +8,16 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('users_discussions', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'users_discussions',
|
||||
function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('discussion_id')->unsigned();
|
||||
$table->dateTime('read_time')->nullable();
|
||||
$table->integer('read_number')->unsigned()->nullable();
|
||||
$table->primary(['user_id', 'discussion_id']);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('users_discussions');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,19 +8,14 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('users_groups', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'users_groups',
|
||||
function (Blueprint $table) {
|
||||
$table->integer('user_id')->unsigned();
|
||||
$table->integer('group_id')->unsigned();
|
||||
$table->primary(['user_id', 'group_id']);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('users_groups');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('users', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'users',
|
||||
function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('username', 100)->unique();
|
||||
$table->string('email', 150)->unique();
|
||||
|
@ -28,10 +28,5 @@ return [
|
|||
$table->dateTime('notification_read_time')->nullable();
|
||||
$table->integer('discussions_count')->unsigned()->default(0);
|
||||
$table->integer('comments_count')->unsigned()->default(0);
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('users');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,19 +8,14 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->create('auth_tokens', function (Blueprint $table) {
|
||||
return Migration::createTable(
|
||||
'auth_tokens',
|
||||
function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('payload', 150);
|
||||
$table->timestamp('created_at');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->drop('auth_tokens');
|
||||
}
|
||||
];
|
||||
);
|
||||
|
|
|
@ -8,20 +8,9 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->dateTime('hide_time')->nullable();
|
||||
$table->integer('hide_user_id')->unsigned()->nullable();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('discussions', function (Blueprint $table) {
|
||||
$table->dropColumn(['hide_time', 'hide_user_id']);
|
||||
});
|
||||
}
|
||||
];
|
||||
return Migration::addColumns('discussions', [
|
||||
'hide_time' => ['dateTime', 'nullable' => true],
|
||||
'hide_user_id' => ['integer', 'unsigned' => true, 'nullable' => true]
|
||||
]);
|
||||
|
|
|
@ -8,19 +8,6 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('notification_read_time', 'notifications_read_time');
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('notifications_read_time', 'notification_read_time');
|
||||
});
|
||||
}
|
||||
];
|
||||
return Migration::renameColumn('users', 'notification_read_time', 'notifications_read_time');
|
||||
|
|
|
@ -8,14 +8,6 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->rename('config', 'settings');
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->rename('settings', 'config');
|
||||
}
|
||||
];
|
||||
return Migration::renameTable('config', 'settings');
|
||||
|
|
|
@ -8,19 +8,8 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->dropColumn(['ip_address']);
|
||||
});
|
||||
}
|
||||
];
|
||||
return Migration::addColumns('posts', [
|
||||
'ip_address' => ['string', 'length' => 45, 'nullable' => true]
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue
Block a user