Sha256: 04aaecfcc5fcdb0821ceb0c3c81d027c6e53811e7b39d135474549fb16c18ea2

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

class CreateVisits < ActiveRecord::Migration
  def self.up
    create_table :visits do |t|
      t.column :person_id, :string
      t.column :elt_id, :string, :null => false
      t.column :created_on, :datetime, :null => false
      t.column :updated_on, :datetime
      t.column :filter, :integer, :default => 0
    end

		execute 'ALTER TABLE visits ADD CONSTRAINT visits_elt_person_key UNIQUE ( elt_id, person_id ) '
		execute 'ALTER TABLE visits ADD CONSTRAINT visits_elt_id FOREIGN KEY ( elt_id ) REFERENCES elts( id ) ON UPDATE CASCADE ON DELETE CASCADE'
		execute 'ALTER TABLE visits ADD CONSTRAINT visits_person_id FOREIGN KEY ( person_id ) REFERENCES people( id ) ON UPDATE CASCADE ON DELETE CASCADE '
  end

  def self.down
    drop_table :visits
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parlement-0.13 db/migrate/007_create_visits.rb
parlement-0.14 db/migrate/007_create_visits.rb
parlement-0.17 db/migrate/007_create_visits.rb