Module: PgSaurus::Migration::CommandRecorder::SchemaMethods

Included in:
PgSaurus::Migration::CommandRecorder
Defined in:
lib/pg_saurus/migration/command_recorder/schema_methods.rb

Overview

Provides methods to extend ActiveRecord::Migration::CommandRecorder to support multi schemas feature.

Instance Method Summary collapse

Instance Method Details

#invert_create_schema(args) ⇒ Object

:nodoc:



18
19
20
# File 'lib/pg_saurus/migration/command_recorder/schema_methods.rb', line 18

def invert_create_schema(args)
  [:drop_schema, [args.first]]
end

#invert_create_schema_if_not_exists(*args) ⇒ Object

:nodoc:



39
40
41
# File 'lib/pg_saurus/migration/command_recorder/schema_methods.rb', line 39

def invert_create_schema_if_not_exists(*args)
  [:drop_schema_if_exists, args]
end

#invert_drop_schema(args) ⇒ Object

:nodoc:



23
24
25
# File 'lib/pg_saurus/migration/command_recorder/schema_methods.rb', line 23

def invert_drop_schema(args)
  [:create_schema, [args.first]]
end

#invert_drop_schema_if_exists(*args) ⇒ Object

:nodoc:



44
45
46
# File 'lib/pg_saurus/migration/command_recorder/schema_methods.rb', line 44

def invert_drop_schema_if_exists(*args)
  [:create_schema_if_not_exists, args]
end

#invert_move_table_to_schema(args) ⇒ Object

:nodoc:



28
29
30
31
32
33
34
35
36
# File 'lib/pg_saurus/migration/command_recorder/schema_methods.rb', line 28

def invert_move_table_to_schema(args)
  table_name     = args.first
  current_schema = args.second

  new_schema, table = ::PgSaurus::Tools.to_schema_and_table(table_name)

  invert_args = ["#{current_schema}.#{table}", new_schema]
  [:move_table_to_schema, invert_args]
end