15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/snaptime/migration_helpers.rb', line 15
def versionize
column :natural_id, :integer
column :valid_from, :timestamp, precision: 3
column :valid_to, :timestamp, precision: 3
column :deleted, :boolean, null: false, default: 0
index :natural_id
index :valid_from
index :valid_to
index %i(natural_id valid_to), unique: true
@base.execute %(
ALTER TABLE "#{name.to_s.upcase}"
ADD CONSTRAINT "#{name.to_s.upcase}_VCVD" CHECK (
VALID_TO IS NULL OR VALID_FROM <= VALID_TO
)
)
end
|