mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-18 13:54:01 +08:00
use laravel migrations to create tables
This commit is contained in:
parent
5fc43ed45b
commit
fbea8e0905
76
database/migrations/2016_11_18_133939_create_all_tables.php
Normal file
76
database/migrations/2016_11_18_133939_create_all_tables.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateAllTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function($table) {
|
||||
$table->increments('uid');
|
||||
$table->string('email', 100);
|
||||
$table->string('nickname', 50)->default('');
|
||||
$table->integer('score');
|
||||
$table->integer('avatar')->default('0');
|
||||
$table->string('password', 255);
|
||||
$table->string('ip', 32);
|
||||
$table->integer('permission')->default('0');
|
||||
$table->dateTime('last_sign_at');
|
||||
$table->dateTime('register_at');
|
||||
});
|
||||
|
||||
Schema::create('closets', function($table) {
|
||||
$table->increments('uid');
|
||||
$table->longText('textures');
|
||||
});
|
||||
|
||||
Schema::create('players', function($table) {
|
||||
$table->increments('pid');
|
||||
$table->integer('uid');
|
||||
$table->string('player_name', 50);
|
||||
$table->string('preference', 10);
|
||||
$table->integer('tid_steve')->default('0');
|
||||
$table->integer('tid_alex')->default('0');
|
||||
$table->integer('tid_cape')->default('0');
|
||||
$table->dateTime('last_modified');
|
||||
});
|
||||
|
||||
Schema::create('textures', function($table) {
|
||||
$table->increments('tid');
|
||||
$table->string('name', 50);
|
||||
$table->string('type', 10);
|
||||
$table->integer('likes');
|
||||
$table->string('hash', 64);
|
||||
$table->integer('size');
|
||||
$table->integer('uploader');
|
||||
$table->integer('public');
|
||||
$table->dateTime('upload_at');
|
||||
});
|
||||
|
||||
Schema::create('options', function($table) {
|
||||
$table->increments('id');
|
||||
$table->string('option_name', 50);
|
||||
$table->longText('option_value');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('users');
|
||||
Schema::drop('closets');
|
||||
Schema::drop('players');
|
||||
Schema::drop('textures');
|
||||
Schema::drop('options');
|
||||
}
|
||||
}
|
41
database/migrations/2016_11_18_134542_import_options.php
Normal file
41
database/migrations/2016_11_18_134542_import_options.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ImportOptions extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// import options
|
||||
$options = config('options');
|
||||
|
||||
$options['version'] = config('app.version');
|
||||
$options['announcement'] = str_replace(
|
||||
'{version}',
|
||||
$options['version'],
|
||||
$options['announcement']
|
||||
);
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
Option::set($key, $value);
|
||||
}
|
||||
|
||||
Option::save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::table('options')->delete();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user