Sha256: e04bf9ca9b0125c73bfa60b615751e931c055b2b425690f8f700679568d4492a

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

begin
  postgres = ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
rescue NameError
  postgres = false
end

ActiveRecord::Schema.define do
  enable_extension 'pgcrypto' if postgres

  create_table :people, temporal: true, force: true do |t|
    t.belongs_to :coven
    t.string :name
  end

  create_table :covens, force: true do |t|
    t.string :name
  end
  add_temporal_table :covens

  create_table :warts, temporal: true, force: true do |t|
    t.belongs_to :person
    t.integer :hairiness
  end

  create_table :flying_machines, temporal: true, force: true do |t|
    t.belongs_to :person
    t.string :type
    t.string :model
  end

  create_table :cats, id: (postgres ? :uuid : :integer), temporal: true, force: true do |t|
    t.string :name
    t.string :color
  end

  create_table :cat_lives, id: (postgres ? :uuid : :integer), temporal: true do |t|
    t.belongs_to :cat, type: (postgres ? :uuid : :integer)
    t.timestamp :started_at
    t.timestamp :ended_at
    t.string :death_reason
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
temporal_tables-1.0.1 spec/internal/db/schema.rb