add column unique numbering scheme, more efficient selects
This commit is contained in:
@@ -30,7 +30,7 @@ END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
PGSQL
|
||||
);
|
||||
DB::unprepared('CREATE SEQUENCE global_row_id_seq START 0 MINVALUE 0;');
|
||||
DB::unprepared('CREATE SEQUENCE IF NOT EXISTS global_row_id_seq START 0 MINVALUE 0;');
|
||||
// We have to increment manually once before the above function can be used - that is because
|
||||
// nextval will return the initial value the first time it's called, so it would not advance by
|
||||
// the given step at all. This would give us negative values - not a problem in postgres without unsigned
|
||||
|
||||
@@ -13,7 +13,7 @@ class MakeGridColumnMandatoryInRowsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::unprepared("ALTER TABLE rows ADD CONSTRAINT grid_must_exist CHECK (data ? '_grid');");
|
||||
DB::unprepared("ALTER TABLE rows ADD CONSTRAINT grid_must_exist CHECK (data ? '_id');");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddColumnSequence extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::unprepared('CREATE SEQUENCE IF NOT EXISTS global_column_id_seq START 0 MINVALUE 0;');
|
||||
// mandatory first increment to make the multi_nextval function work
|
||||
DB::select("SELECT nextval('global_column_id_seq') as nv;");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::unprepared('DROP SEQUENCE IF EXISTS global_column_id_seq;');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user