Class: PGSpecHelper::TableExecuter
- Inherits:
-
Object
- Object
- PGSpecHelper::TableExecuter
- Defined in:
- lib/pg_spec_helper/table_executer.rb
Instance Method Summary collapse
- #add_column(column_name, type, null = true) ⇒ Object
- #add_foreign_key(column_names, foreign_schema_name, foreign_table_name, foreign_column_names, foreign_key_name) ⇒ Object
- #add_index(column_names, index_name, unique = false) ⇒ Object
- #add_primary_key(column_names, primary_key_name) ⇒ Object
- #add_unique_constraint(column_names, constraint_key_name) ⇒ Object
- #add_validation(validation_name, check_clause) ⇒ Object
-
#initialize(pg_spec_helper, schema_name, table_name, &block) ⇒ TableExecuter
constructor
A new instance of TableExecuter.
Constructor Details
#initialize(pg_spec_helper, schema_name, table_name, &block) ⇒ TableExecuter
Returns a new instance of TableExecuter.
5 6 7 8 9 10 |
# File 'lib/pg_spec_helper/table_executer.rb', line 5 def initialize pg_spec_helper, schema_name, table_name, &block @pg_spec_helper = pg_spec_helper @schema_name = schema_name @table_name = table_name instance_exec(&block) end |
Instance Method Details
#add_column(column_name, type, null = true) ⇒ Object
12 13 14 |
# File 'lib/pg_spec_helper/table_executer.rb', line 12 def add_column column_name, type, null = true @pg_spec_helper.create_column @schema_name, @table_name, column_name, type, null end |
#add_foreign_key(column_names, foreign_schema_name, foreign_table_name, foreign_column_names, foreign_key_name) ⇒ Object
16 17 18 |
# File 'lib/pg_spec_helper/table_executer.rb', line 16 def add_foreign_key column_names, foreign_schema_name, foreign_table_name, foreign_column_names, foreign_key_name @pg_spec_helper.create_foreign_key @schema_name, @table_name, column_names, foreign_schema_name, foreign_table_name, foreign_column_names, foreign_key_name end |
#add_index(column_names, index_name, unique = false) ⇒ Object
20 21 22 |
# File 'lib/pg_spec_helper/table_executer.rb', line 20 def add_index column_names, index_name, unique = false @pg_spec_helper.create_index @schema_name, @table_name, column_names, index_name end |
#add_primary_key(column_names, primary_key_name) ⇒ Object
24 25 26 |
# File 'lib/pg_spec_helper/table_executer.rb', line 24 def add_primary_key column_names, primary_key_name @pg_spec_helper.create_primary_key @schema_name, @table_name, column_names, primary_key_name end |
#add_unique_constraint(column_names, constraint_key_name) ⇒ Object
28 29 30 |
# File 'lib/pg_spec_helper/table_executer.rb', line 28 def add_unique_constraint column_names, constraint_key_name @pg_spec_helper.create_unique_constraint @schema_name, @table_name, column_names, constraint_key_name end |
#add_validation(validation_name, check_clause) ⇒ Object
32 33 34 |
# File 'lib/pg_spec_helper/table_executer.rb', line 32 def add_validation validation_name, check_clause @pg_spec_helper.create_validation @schema_name, @table_name, validation_name, check_clause end |