Method: Sequent::Migrations::Versions.migration_sql

Defined in:
lib/sequent/migrations/versions.rb

.migration_sqlObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/sequent/migrations/versions.rb', line 11

def self.migration_sql
  <<~SQL.chomp
    CREATE TABLE IF NOT EXISTS #{table_name} (version integer NOT NULL, CONSTRAINT version_pk PRIMARY KEY(version));
    ALTER TABLE #{table_name} drop constraint if exists only_one_running;
    ALTER TABLE #{table_name} ADD COLUMN IF NOT EXISTS status INTEGER DEFAULT NULL CONSTRAINT only_one_running CHECK (status in (1,2,3));
    ALTER TABLE #{table_name} ADD COLUMN IF NOT EXISTS xmin_xact_id BIGINT;
    DROP INDEX IF EXISTS single_migration_running;
    CREATE UNIQUE INDEX single_migration_running ON #{table_name} ((status * 0)) where status is not null;
  SQL
end