Skip to content

Commit

Permalink
fix: 创建setting_datasource表之前,检查表是否存在
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jul 27, 2023
1 parent b3362d9 commit be0d45d
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ class UpdateVersion120 extends Migration
*/
public function up(): void
{
Schema::create('setting_datasource', function (Blueprint $table) {
$table->engine = 'Innodb';
$table->comment('数据源表');
$table->bigIncrements('id')->comment('主键');
$table->addColumn('string', 'source_name', ['length' => 32, 'comment' => '数据源名称']);
$table->addColumn('string', 'dsn', ['length'=> 255, 'comment' => '连接dsn字符串'])->nullable();
$table->addColumn('string', 'username', ['length'=> 64, 'comment' => '数据库名称'])->nullable();
$table->addColumn('string', 'password', ['length'=> 32, 'comment' => '数据库用户'])->nullable();
$table->addColumn('bigInteger', 'created_by', ['comment' => '创建者'])->nullable();
$table->addColumn('bigInteger', 'updated_by', ['comment' => '更新者'])->nullable();
$table->addColumn('timestamp', 'created_at', ['precision' => 0, 'comment' => '创建时间'])->nullable();
$table->addColumn('timestamp', 'updated_at', ['precision' => 0, 'comment' => '更新时间'])->nullable();
$table->addColumn('string', 'remark', ['length' => 255, 'comment' => '备注'])->nullable();
});

if (! Schema::hasTable('setting_datasource')) {
Schema::create('setting_datasource', function (Blueprint $table) {
$table->engine = 'Innodb';
$table->comment('数据源表');
$table->bigIncrements('id')->comment('主键');
$table->addColumn('string', 'source_name', ['length' => 32, 'comment' => '数据源名称']);
$table->addColumn('string', 'dsn', ['length'=> 255, 'comment' => '连接dsn字符串'])->nullable();
$table->addColumn('string', 'username', ['length'=> 64, 'comment' => '数据库名称'])->nullable();
$table->addColumn('string', 'password', ['length'=> 32, 'comment' => '数据库用户'])->nullable();
$table->addColumn('bigInteger', 'created_by', ['comment' => '创建者'])->nullable();
$table->addColumn('bigInteger', 'updated_by', ['comment' => '更新者'])->nullable();
$table->addColumn('timestamp', 'created_at', ['precision' => 0, 'comment' => '创建时间'])->nullable();
$table->addColumn('timestamp', 'updated_at', ['precision' => 0, 'comment' => '更新时间'])->nullable();
$table->addColumn('string', 'remark', ['length' => 255, 'comment' => '备注'])->nullable();
});
}
// 菜单数据
$pid = Db::table('system_menu')->insertGetId(
[
Expand Down

0 comments on commit be0d45d

Please sign in to comment.