ActiveRecord.MigrationGenerator class
Part of Active Record
Generates migration files for the flux generate migration <Name> [column:type ...]
console command. The name of the migration decides what its change starts out with:
a create_table for 'Create<Table>', add_column calls for 'Add<Columns>To<Table>'
and remove_column calls for 'Remove<Columns>From<Table>'. The file is written into
the db/migrate/ folder of the active schema under a new version.
Summary
Methods
Methods
ActiveRecord.MigrationGenerator:body()
shared packages/active_record/lib/migrator/migration_generator.lua:53Returns the body of the generated #change, indented by two spaces.
Returns
- String
ActiveRecord.MigrationGenerator:generate(context)
shared packages/active_record/lib/migrator/migration_generator.lua:134Writes the migration file into the schema's migrations folder, with a new version.
Parameters
- context ActiveRecord::MigrationContext optional, defaults to
nilcontext whose first path the file is written to; the default context if none is given
Returns
- String path of the file, relative to the game folder
ActiveRecord.MigrationGenerator:init(name, fields)
shared packages/active_record/lib/migrator/migration_generator.lua:21Creates a generator for a migration file. The name decides the contents of the generated #change: 'Create<Table>' creates the table with the given columns, 'Add<Columns>To<Table>' adds the columns and 'Remove<Columns>From<Table>' removes them; any other name gives an empty #change.
ActiveRecord.MigrationGenerator.new('AddRoleToUsers', { 'role:string' }):generate()
Parameters
- name String name in CamelCase or snake_case
- fields List<String> optional, defaults to
nilcolumns as 'name:type' ('string' if no type is given, 'references' for a reference column)
Returns
- ActiveRecord::MigrationGenerator(self)
ActiveRecord.MigrationGenerator:render()
shared packages/active_record/lib/migrator/migration_generator.lua:114Returns the source of the migration file.
Returns
- String