Class: DbSchema::Migrator::BodyYielder
- Inherits:
-
Object
- Object
- DbSchema::Migrator::BodyYielder
show all
- Defined in:
- lib/db_schema/migrator.rb
Defined Under Namespace
Classes: AlterTableYielder
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(connection) ⇒ BodyYielder
Returns a new instance of BodyYielder.
24
25
26
|
# File 'lib/db_schema/migrator.rb', line 24
def initialize(connection)
@connection = connection
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
22
23
24
|
# File 'lib/db_schema/migrator.rb', line 22
def connection
@connection
end
|
Instance Method Details
#alter_table(name, &block) ⇒ Object
54
55
56
|
# File 'lib/db_schema/migrator.rb', line 54
def alter_table(name, &block)
run AlterTableYielder.new(name).run(block)
end
|
#create_enum(name, values) ⇒ Object
161
162
163
|
# File 'lib/db_schema/migrator.rb', line 161
def create_enum(name, values)
run Operations::CreateEnum.new(Definitions::Enum.new(name, values))
end
|
#create_extension(name) ⇒ Object
173
174
175
|
# File 'lib/db_schema/migrator.rb', line 173
def create_extension(name)
run Operations::CreateExtension.new(Definitions::Extension.new(name))
end
|
#create_table(name, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/db_schema/migrator.rb', line 28
def create_table(name, &block)
table_yielder = DSL::TableYielder.new(name, block)
table = Definitions::Table.new(
name,
fields: table_yielder.fields,
indexes: table_yielder.indexes,
checks: table_yielder.checks,
foreign_keys: table_yielder.foreign_keys
)
run Operations::CreateTable.new(table)
table.foreign_keys.each do |fkey|
run Operations::CreateForeignKey.new(table.name, fkey)
end
end
|
#drop_enum(name) ⇒ Object
165
166
167
|
# File 'lib/db_schema/migrator.rb', line 165
def drop_enum(name)
run Operations::DropEnum.new(name)
end
|
#drop_extension(name) ⇒ Object
#drop_table(name) ⇒ Object
46
47
48
|
# File 'lib/db_schema/migrator.rb', line 46
def drop_table(name)
run Operations::DropTable.new(name)
end
|
#rename_enum(from, to:) ⇒ Object
169
170
171
|
# File 'lib/db_schema/migrator.rb', line 169
def rename_enum(from, to:)
run Operations::RenameEnum.new(old_name: from, new_name: to)
end
|
#rename_table(from, to:) ⇒ Object
50
51
52
|
# File 'lib/db_schema/migrator.rb', line 50
def rename_table(from, to:)
run Operations::RenameTable.new(old_name: from, new_name: to)
end
|