Skip to content
This repository has been archived by the owner on Aug 25, 2018. It is now read-only.

Commit

Permalink
Allow passing name
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcsmith committed May 12, 2018
1 parent 0a17cbd commit c83bebc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/lucky_migrator/runner.cr
Expand Up @@ -3,6 +3,8 @@ require "pg"
require "colorize"

class LuckyMigrator::Runner
MIGRATIONS_TABLE_NAME = "migrations"

extend LuckyCli::TextHelpers

@@migrations = [] of LuckyMigrator::Migration::V1.class
Expand Down Expand Up @@ -152,7 +154,7 @@ class LuckyMigrator::Runner

private def create_table_for_tracking_migrations
<<-SQL
CREATE TABLE IF NOT EXISTS migrations (
CREATE TABLE IF NOT EXISTS #{MIGRATIONS_TABLE_NAME} (
id serial PRIMARY KEY,
version bigint NOT NULL
)
Expand Down
8 changes: 4 additions & 4 deletions src/lucky_migrator/tasks/gen/migration.cr
Expand Up @@ -59,12 +59,12 @@ end
class Gen::Migration < LuckyCli::Task
banner "Generate a new migration"

def call
def call(name : String? = nil)
LuckyMigrator.run do
if ARGV.first? == nil
raise "Migration name is required. Example: lucky gen.migration CreateUsers".colorize(:red).to_s
if ARGV.first? || name
LuckyMigrator::MigrationGenerator.new(name: name).generate
else
LuckyMigrator::MigrationGenerator.new(name: ARGV.first).generate
raise "Migration name is required. Example: lucky gen.migration CreateUsers".colorize(:red).to_s
end
end
end
Expand Down

0 comments on commit c83bebc

Please sign in to comment.