Class: Stitches::ApiMigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/stitches/api_migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



9
10
11
# File 'lib/stitches/api_migration_generator.rb', line 9

def self.next_migration_number(path)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#bootstrap_api_migrationObject



14
15
16
17
18
19
20
21
# File 'lib/stitches/api_migration_generator.rb', line 14

def bootstrap_api_migration
  copy_file "app/models/api_client.rb"
  copy_file "lib/tasks/generate_api_key.rake"

  migration_template "db/migrate/enable_uuid_ossp_extension.rb", "db/migrate/enable_uuid_ossp_extension.rb"
  sleep 1 # allow clock to tick so we get different numbers
  migration_template "db/migrate/create_api_clients.rb", "db/migrate/create_api_clients.rb"
end