Module: DbAgile::SequelAdapter::Schema::TransactionDriven
- Included in:
- DbAgile::SequelAdapter
- Defined in:
- lib/dbagile/adapter/sequel/schema/transaction_driven.rb
Instance Method Summary collapse
- #add_columns(transaction, table, columns) ⇒ Object
- #create_table(transaction, name, columns) ⇒ Object
- #drop_table(transaction, table_name) ⇒ Object
- #key!(transaction, table_name, columns) ⇒ Object
- #run_schema_script(transaction, script, options) ⇒ Object
Instance Method Details
#add_columns(transaction, table, columns) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/dbagile/adapter/sequel/schema/transaction_driven.rb', line 31 def add_columns(transaction, table, columns) db.alter_table(table) do columns.each_pair{|name, type| add_column name, type} end true end |
#create_table(transaction, name, columns) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/dbagile/adapter/sequel/schema/transaction_driven.rb', line 17 def create_table(transaction, name, columns) db.create_table(name){ columns.each_pair{|name, type| column(name, type)} } columns end |
#drop_table(transaction, table_name) ⇒ Object
25 26 27 28 |
# File 'lib/dbagile/adapter/sequel/schema/transaction_driven.rb', line 25 def drop_table(transaction, table_name) db.drop_table(table_name) true end |
#key!(transaction, table_name, columns) ⇒ Object
39 40 41 |
# File 'lib/dbagile/adapter/sequel/schema/transaction_driven.rb', line 39 def key!(transaction, table_name, columns) db.add_index(table_name, columns, {:unique => true}) end |
#run_schema_script(transaction, script, options) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/dbagile/adapter/sequel/schema/transaction_driven.rb', line 7 def run_schema_script(transaction, script, ) buffer = "" SequelAdapter::Schema::Stager.new(db).run(schema, buffer, ) unless [:dry_run] db.execute_ddl(buffer) end buffer end |