Class: CreateImports

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/synchronisable/templates/create_imports_migration.rb

Class Method Summary collapse

Class Method Details

.downObject


19
20
21
22
23
24
25
# File 'lib/generators/synchronisable/templates/create_imports_migration.rb', line 19

def self.down
  remove_index :imports, :remote_id
  remove_index :imports, :synchronisable_id
  remove_index :imports, [:synchronisable_type, :remote_id]
  remove_index :imports, [:synchronisable_type, :unique_id]
  drop_table :imports
end

.upObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/synchronisable/templates/create_imports_migration.rb', line 2

def self.up
  create_table :imports do |t|
    t.string  :synchronisable_type, null: false
    t.integer :synchronisable_id, null: false
    t.text    :attrs
    t.string  :remote_id, null: false
    t.string  :unique_id

    t.timestamps null: false
  end

  add_index :imports, :remote_id
  add_index :imports, [:synchronisable_type, :synchronisable_id]
  add_index :imports, [:synchronisable_type, :remote_id]
  add_index :imports, [:synchronisable_type, :unique_id]
end