зеркало из https://github.com/github/github-ds.git
update migration generator test to rely on config table name
should we do this though? i can see an argument where we actually keep the test as is because the default `table_name` is still `key_values` and we're trying to maintain original usage expectations with this PR
This commit is contained in:
Родитель
d939c8ac0b
Коммит
e8acbedb52
|
@ -17,24 +17,25 @@ class GithubDSActiveRecordGeneratorTest < Rails::Generators::TestCase
|
||||||
else
|
else
|
||||||
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
||||||
end
|
end
|
||||||
|
table_name = "key_values"
|
||||||
assert_migration "db/migrate/create_key_values_table.rb", <<-EOM
|
assert_migration "db/migrate/create_key_values_table.rb", <<-EOM
|
||||||
class CreateKeyValuesTable < ActiveRecord::Migration#{migration_version}
|
class CreateKeyValuesTable < ActiveRecord::Migration#{migration_version}
|
||||||
def self.up
|
def self.up
|
||||||
create_table :key_values do |t|
|
create_table :#{table_name} do |t|
|
||||||
t.string :key, :null => false
|
t.string :key, :null => false
|
||||||
t.binary :value, :null => false
|
t.binary :value, :null => false
|
||||||
t.datetime :expires_at, :null => true
|
t.datetime :expires_at, :null => true
|
||||||
t.timestamps :null => false
|
t.timestamps :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index :key_values, :key, :unique => true
|
add_index :#{table_name}, :key, :unique => true
|
||||||
add_index :key_values, :expires_at
|
add_index :#{table_name}, :expires_at
|
||||||
|
|
||||||
change_column :key_values, :id, "bigint(20) NOT NULL AUTO_INCREMENT"
|
change_column :#{table_name}, :id, "bigint(20) NOT NULL AUTO_INCREMENT"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
drop_table :key_values
|
drop_table :#{table_name}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
EOM
|
EOM
|
||||||
|
|
Загрузка…
Ссылка в новой задаче