Class: Glueby::Contract::TokenGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Extended by:
Generator::MigrateGenerator::ClassMethod
Includes:
Generator::MigrateGenerator, Rails::Generators::Migration
Defined in:
lib/generators/glueby/contract/token_generator.rb

Constant Summary

Constants included from Generator::MigrateGenerator

Generator::MigrateGenerator::MYSQL_ADAPTERS

Instance Method Summary collapse

Methods included from Generator::MigrateGenerator::ClassMethod

next_migration_number

Methods included from Generator::MigrateGenerator

#migration_version, #mysql?, #table_options

Instance Method Details

#create_migration_fileObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/glueby/contract/token_generator.rb', line 10

def create_migration_file
  migration_dir = File.expand_path("db/migrate")

  if self.class.migration_exists?(migration_dir, "create_token_metadata")
    ::Kernel.warn "Migration already exists: create_token_metadata"
  else
    migration_template(
      "token_metadata_table.rb.erb",
      "db/migrate/create_token_metadata.rb",
      migration_version: migration_version,
      table_options: table_options,
    )
  end

  if self.class.migration_exists?(migration_dir, "create_reissuable_token")
    ::Kernel.warn "Migration already exists: create_reissuable_token"
  else
    migration_template(
      "reissuable_token_table.rb.erb",
      "db/migrate/create_reissuable_token.rb",
      migration_version: migration_version,
      table_options: table_options,
    )
  end
end