Module: ActiveRecord::Turntable::Migration::SchemaStatementsExt
- Defined in:
- lib/active_record/turntable/migration.rb
Instance Method Summary collapse
- #create_sequence_for(table_name, options = {}) ⇒ Object
- #drop_sequence_for(table_name, options = {}) ⇒ Object
- #rename_sequence_for(table_name, new_name) ⇒ Object
Instance Method Details
#create_sequence_for(table_name, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_record/turntable/migration.rb', line 51 def create_sequence_for(table_name, = {}) = .merge(id: false) # TODO: pkname should be pulled from table definitions sequence_table_name = ActiveRecord::Turntable::Sequencer.sequence_name(table_name, "id") create_table(sequence_table_name, ) do |t| t.integer :id, limit: 8 end execute "INSERT INTO #{quote_table_name(sequence_table_name)} (`id`) VALUES (0)" end |
#drop_sequence_for(table_name, options = {}) ⇒ Object
62 63 64 65 66 |
# File 'lib/active_record/turntable/migration.rb', line 62 def drop_sequence_for(table_name, = {}) # TODO: pkname should be pulled from table definitions sequence_table_name = ActiveRecord::Turntable::Sequencer.sequence_name(table_name, "id") drop_table(sequence_table_name) end |
#rename_sequence_for(table_name, new_name) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/active_record/turntable/migration.rb', line 68 def rename_sequence_for(table_name, new_name) # TODO: pkname should pulled from table definitions seq_table_name = ActiveRecord::Turntable::Sequencer.sequence_name(table_name, "id") new_seq_name = ActiveRecord::Turntable::Sequencer.sequence_name(new_name, "id") rename_table(seq_table_name, new_seq_name) end |