Merge pull request #66 from redrick/master

Add migration version for Rails 5 and above
This commit is contained in:
Dzmitry Plashchynski
2017-10-19 21:19:48 +03:00
committed by GitHub
2 changed files with 14 additions and 7 deletions

View File

@@ -21,7 +21,18 @@ module Crono
def create_migrations
migration_template 'migrations/create_crono_jobs.rb',
'db/migrate/create_crono_jobs.rb'
'db/migrate/create_crono_jobs.rb',
migration_version: migration_version
end
def rails5?
Rails.version.start_with? '5'
end
def migration_version
if rails5?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
end
end

View File

@@ -1,5 +1,5 @@
class CreateCronoJobs < ActiveRecord::Migration
def self.up
class CreateCronoJobs < ActiveRecord::Migration<%= migration_version %>
def change
create_table :crono_jobs do |t|
t.string :job_id, null: false
t.text :log, limit: 1073741823 # LONGTEXT for MySQL
@@ -9,8 +9,4 @@ class CreateCronoJobs < ActiveRecord::Migration
end
add_index :crono_jobs, [:job_id], unique: true
end
def self.down
drop_table :crono_jobs
end
end