osb/database/migrations/2021_06_30_171340_rename_setup.php

62 lines
1.9 KiB
PHP
Raw Normal View History

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RenameSetup extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ab_setup', function (Blueprint $table) {
$table->dropForeign('fk_set_acc');
$table->dropForeign('fk_set_cty');
$table->dropForeign('fk_set_cur');
$table->dropForeign('fk_set_lan');
});
Schema::table('ab_setup', function (Blueprint $table) {
$table->dropIndex('fk_set_cty_idx');
$table->dropIndex('fk_set_cur_idx');
$table->dropIndex('fk_set_lan_idx');
$table->dropIndex('fk_set_acc_idx');
});
DB::statement('ALTER TABLE ab_setup RENAME TO sites');
DB::statement('ALTER TABLE sites MODIFY url VARCHAR(256) NOT NULL');
DB::statement('ALTER TABLE sites CHANGE COLUMN id site_id INT NOT NULL');
DB::statement('ALTER TABLE sites MODIFY admin_id INT(10) UNSIGNED NOT NULL');
DB::statement('ALTER TABLE sites MODIFY active TINYINT(1) NOT NULL');
Schema::table('sites', function (Blueprint $table) {
$table->index(['site_id']);
$table->dropPrimary(['site_id','country_id','currency_id','url']);
});
Schema::table('sites', function (Blueprint $table) {
$table->integer('id',TRUE)->first();
$table->unique(['site_id','url']);
$table->dropColumn(['login_expire','time_format','date_format','decimal_place','module_config','site_details']);
$table->foreign('country_id')->references('id')->on('ab_country');
$table->foreign('currency_id')->references('id')->on('ab_currency');
$table->foreign('language_id')->references('id')->on('ab_language');
$table->foreign(['admin_id','site_id'])->references(['id','site_id'])->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'cant go back');
}
}