#55 マイグレーション・ファイルのみ
このコミットが含まれているのは:
@@ -0,0 +1,20 @@
|
|||||||
|
class CreateLanguages < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
create_table :languages, id: { type: :string, limit: 16 }, primary_key: :code do |t|
|
||||||
|
t.string :name, null: false
|
||||||
|
t.datetime :deprecated_at, index: true
|
||||||
|
t.datetime :created_at, null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
execute <<~SQL
|
||||||
|
INSERT INTO
|
||||||
|
languages(code, name, created_at)
|
||||||
|
VALUES
|
||||||
|
('ja', '日本語', #{ connection.quote Time.current })
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :languages
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
class CreateScripts < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
create_table :scripts, id: { type: 'CHAR(4)' }, primary_key: :code do |t|
|
||||||
|
t.string :name, null: false
|
||||||
|
t.datetime :deprecated_at, index: true
|
||||||
|
t.datetime :created_at, null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
execute <<~SQL
|
||||||
|
INSERT INTO
|
||||||
|
scripts(code, name, created_at)
|
||||||
|
VALUES
|
||||||
|
('Jpan', '漢字および仮名文字', #{ connection.quote Time.current })
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :scripts
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
class CreateLocales < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
create_table :locales, id: { type: :string, limit: 32 }, primary_key: :code do |t|
|
||||||
|
t.string :language_code, limit: 16, null: false, index: true
|
||||||
|
t.column :script_code, 'CHAR(4)', null: false
|
||||||
|
t.string :name, null: false
|
||||||
|
t.datetime :deprecated_at, index: true
|
||||||
|
t.datetime :created_at, null: false
|
||||||
|
|
||||||
|
t.foreign_key :languages, column: :language_code, primary_key: :code
|
||||||
|
t.foreign_key :scripts, column: :script_code, primary_key: :code
|
||||||
|
end
|
||||||
|
|
||||||
|
execute <<~SQL
|
||||||
|
INSERT INTO
|
||||||
|
locales(code, language_code, script_code, name, created_at)
|
||||||
|
VALUES
|
||||||
|
('ja', 'ja', 'Jpan', '日本語', #{ connection.quote Time.current })
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
drop_table :locales
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
class AddColumnsToTagNames < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
add_column :tag_names, :language_code, :string,
|
||||||
|
limit: 16, null: false, after: :id, default: 'ja'
|
||||||
|
add_column :tag_names, :script_code, 'CHAR(4)',
|
||||||
|
null: false, after: :name, default: 'Jpan'
|
||||||
|
|
||||||
|
add_foreign_key :tag_names, :languages, column: :language_code, primary_key: :code
|
||||||
|
add_foreign_key :tag_names, :scripts, column: :script_code, primary_key: :code
|
||||||
|
|
||||||
|
remove_index :tag_names, :name
|
||||||
|
add_index :tag_names, [:language_code, :name], unique: true
|
||||||
|
|
||||||
|
change_column_default :tag_names, :language_code, from: 'ja', to: nil
|
||||||
|
change_column_default :tag_names, :script_code, from: 'Jpan', to: nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_foreign_key :tag_names, column: :language_code
|
||||||
|
remove_foreign_key :tag_names, column: :script_code
|
||||||
|
|
||||||
|
remove_index :tag_names, [:language_code, :name]
|
||||||
|
add_index :tag_names, :name, unique: true
|
||||||
|
|
||||||
|
remove_column :tag_names, :script_code
|
||||||
|
remove_column :tag_names, :language_code
|
||||||
|
end
|
||||||
|
end
|
||||||
新しいイシューから参照
ユーザーをブロックする