Skip to content

Commit

Permalink
update dummy migration files
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Mar 20, 2019
1 parent 218cba9 commit 1a695d3
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 38 deletions.
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/124_create_bookstores.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateBookstores < ActiveRecord::Migration[5.2]
def change
create_table :bookstores do |t|
create_table :bookstores, id: :uuid do |t|
t.text :name, null: false
t.string :zip_code
t.text :address
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/133_create_agent_merges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreateAgentMerges < ActiveRecord::Migration[5.2]
def change
create_table :agent_merges do |t|
t.references :agent, foreign_key: true, null: false, type: :uuid
t.references :agent_merge_list, null: false
t.references :agent_merge_list, null: false, type: :uuid

t.timestamps
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/134_create_agent_merge_lists.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateAgentMergeLists < ActiveRecord::Migration[5.2]
def change
create_table :agent_merge_lists do |t|
create_table :agent_merge_lists, id: :uuid do |t|
t.string :title

t.timestamps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateSubscriptions < ActiveRecord::Migration[5.2]
def change
create_table :subscriptions do |t|
create_table :subscriptions, id: :uuid do |t|
t.text :title, null: false
t.text :note
t.references :user, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20081006093246_create_subscribes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateSubscribes < ActiveRecord::Migration[5.2]
def change
create_table :subscribes do |t|
t.references :subscription, foreign_key: true, null: false
t.references :subscription, foreign_key: true, null: false, type: :uuid
t.references :work, null: false, type: :uuid
t.datetime :start_at, null: false
t.datetime :end_at, null: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateSeriesStatements < ActiveRecord::Migration[5.2]
def change
create_table :series_statements do |t|
t.text :title
create_table :series_statements, id: :uuid do |t|
t.text :title, null: false
t.text :numbering
t.text :title_subseries
t.text :numbering_subseries
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateImportRequests < ActiveRecord::Migration[5.2]
def change
create_table :import_requests do |t|
create_table :import_requests, id: :uuid do |t|
t.string :isbn, index: true, null: false
t.references :manifestation, foreign_key: true, type: :uuid
t.references :user, foreign_key: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddBookstoreIdToItem < ActiveRecord::Migration[5.2]
def change
add_reference :items, :bookstore, foreign_key: true
add_reference :items, :bookstore, foreign_key: true, type: :uuid
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateSeriesStatementMergeLists < ActiveRecord::Migration[5.2]
def change
create_table :series_statement_merge_lists do |t|
create_table :series_statement_merge_lists, id: :uuid do |t|
t.string :title

t.timestamps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class CreateSeriesStatementMerges < ActiveRecord::Migration[5.2]
def change
create_table :series_statement_merges do |t|
t.references :series_statement, foreign_key: true, null: false
t.references :series_statement_merge_list, foreign_key: true, index: false, null: false
t.references :series_statement, foreign_key: true, null: false, type: :uuid
t.references :series_statement_merge_list, foreign_key: true, index: false, null: false, type: :uuid

t.timestamps
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20120319173203_create_accepts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateAccepts < ActiveRecord::Migration[5.2]
def change
create_table :accepts do |t|
create_table :accepts, id: :uuid do |t|
t.references :basket, foreign_key: true, type: :uuid
t.references :item, type: :uuid
t.references :librarian, foreign_key: {to_table: :users}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def change
t.string :to_state
t.jsonb :metadata, default: {}
t.integer :sort_key
t.references :import_request
t.references :import_request, type: :uuid
t.timestamps
end

Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20150924115059_create_withdraws.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateWithdraws < ActiveRecord::Migration[5.2]
def change
create_table :withdraws do |t|
create_table :withdraws, id: :uuid do |t|
t.references :basket, foreign_key: true, type: :uuid
t.references :item, type: :uuid
t.references :librarian, foreign_key: {to_table: :users}
Expand Down
10 changes: 10 additions & 0 deletions spec/dummy/db/migrate/20190311154610_create_periodicals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreatePeriodicals < ActiveRecord::Migration[5.2]
def change
create_table :periodicals, id: :uuid do |t|
t.text :original_title, null: false
t.references :frequency, foreign_key: true, null: false

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CreatePeriodicalAndManifestations < ActiveRecord::Migration[5.2]
def change
create_table :periodical_and_manifestations do |t|
t.references :periodical, foreign_key: true, type: :uuid, null: false
t.references :manifestation, foreign_key: true, type: :uuid, null: false
t.boolean :periodical_master, default: false, null: false, index: {where: 'periodical_master IS true', unique: true}

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddFullNameTranslationsToCreate < ActiveRecord::Migration[5.2]
def change
add_column :creates, :full_name_translations, :jsonb, default: {}
add_column :realizes, :full_name_translations, :jsonb, default: {}
add_column :produces, :full_name_translations, :jsonb, default: {}
end
end
57 changes: 41 additions & 16 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_02_08_135957) do
ActiveRecord::Schema.define(version: 2019_03_14_151124) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"

create_table "accepts", force: :cascade do |t|
create_table "accepts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "basket_id"
t.uuid "item_id"
t.bigint "librarian_id"
Expand Down Expand Up @@ -84,15 +84,15 @@
t.index ["agent_import_file_id"], name: "index_agent_import_results_on_agent_import_file_id"
end

create_table "agent_merge_lists", force: :cascade do |t|
create_table "agent_merge_lists", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "title"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "agent_merges", force: :cascade do |t|
t.uuid "agent_id", null: false
t.bigint "agent_merge_list_id", null: false
t.uuid "agent_merge_list_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["agent_id"], name: "index_agent_merges_on_agent_id"
Expand Down Expand Up @@ -191,7 +191,7 @@
t.index ["user_id"], name: "index_baskets_on_user_id"
end

create_table "bookstores", force: :cascade do |t|
create_table "bookstores", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "name", null: false
t.string "zip_code"
t.text "address"
Expand Down Expand Up @@ -300,6 +300,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "create_type_id"
t.jsonb "full_name_translations", default: {}
t.index ["agent_id"], name: "index_creates_on_agent_id"
t.index ["work_id"], name: "index_creates_on_work_id"
end
Expand Down Expand Up @@ -383,7 +384,7 @@
t.string "to_state"
t.jsonb "metadata", default: {}
t.integer "sort_key"
t.bigint "import_request_id"
t.uuid "import_request_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
Expand All @@ -392,7 +393,7 @@
t.index ["sort_key", "import_request_id"], name: "index_import_request_transitions_on_sort_key_and_request_id", unique: true
end

create_table "import_requests", force: :cascade do |t|
create_table "import_requests", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "isbn", null: false
t.uuid "manifestation_id"
t.bigint "user_id"
Expand Down Expand Up @@ -454,7 +455,7 @@
t.integer "lock_version", default: 0, null: false
t.integer "required_role_id", default: 1, null: false
t.datetime "acquired_at"
t.bigint "bookstore_id"
t.uuid "bookstore_id"
t.integer "budget_type_id"
t.string "binding_item_identifier"
t.string "binding_call_number"
Expand Down Expand Up @@ -676,6 +677,25 @@
t.index ["item_id"], name: "index_owns_on_item_id"
end

create_table "periodical_and_manifestations", force: :cascade do |t|
t.uuid "periodical_id", null: false
t.uuid "manifestation_id", null: false
t.boolean "periodical_master", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["manifestation_id"], name: "index_periodical_and_manifestations_on_manifestation_id"
t.index ["periodical_id"], name: "index_periodical_and_manifestations_on_periodical_id"
t.index ["periodical_master"], name: "index_periodical_and_manifestations_on_periodical_master", unique: true, where: "(periodical_master IS TRUE)"
end

create_table "periodicals", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "original_title", null: false
t.bigint "frequency_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["frequency_id"], name: "index_periodicals_on_frequency_id"
end

create_table "picture_files", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "picture_attachable_id", null: false
t.string "picture_attachable_type", null: false
Expand Down Expand Up @@ -707,6 +727,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "produce_type_id"
t.jsonb "full_name_translations", default: {}
t.index ["agent_id"], name: "index_produces_on_agent_id"
t.index ["manifestation_id"], name: "index_produces_on_manifestation_id"
end
Expand Down Expand Up @@ -745,6 +766,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "realize_type_id"
t.jsonb "full_name_translations", default: {}
t.index ["agent_id"], name: "index_realizes_on_agent_id"
t.index ["expression_id"], name: "index_realizes_on_expression_id"
end
Expand Down Expand Up @@ -853,23 +875,23 @@
t.datetime "updated_at", null: false
end

create_table "series_statement_merge_lists", force: :cascade do |t|
create_table "series_statement_merge_lists", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "title"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "series_statement_merges", force: :cascade do |t|
t.bigint "series_statement_id", null: false
t.bigint "series_statement_merge_list_id", null: false
t.uuid "series_statement_id", null: false
t.uuid "series_statement_merge_list_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["series_statement_id"], name: "index_series_statement_merges_on_series_statement_id"
t.index ["series_statement_merge_list_id"], name: "index_series_statement_merges_on_list_id"
end

create_table "series_statements", force: :cascade do |t|
t.text "original_title"
create_table "series_statements", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "original_title", null: false
t.text "numbering"
t.text "title_subseries"
t.text "numbering_subseries"
Expand Down Expand Up @@ -948,7 +970,7 @@
end

create_table "subscribes", force: :cascade do |t|
t.bigint "subscription_id", null: false
t.uuid "subscription_id", null: false
t.uuid "work_id", null: false
t.datetime "start_at", null: false
t.datetime "end_at", null: false
Expand All @@ -958,7 +980,7 @@
t.index ["work_id"], name: "index_subscribes_on_work_id"
end

create_table "subscriptions", force: :cascade do |t|
create_table "subscriptions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "title", null: false
t.text "note"
t.bigint "user_id"
Expand Down Expand Up @@ -1079,7 +1101,7 @@
t.index ["username"], name: "index_users_on_username", unique: true
end

create_table "withdraws", force: :cascade do |t|
create_table "withdraws", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "basket_id"
t.uuid "item_id"
t.bigint "librarian_id"
Expand Down Expand Up @@ -1125,6 +1147,9 @@
add_foreign_key "manifestation_relationships", "manifestations", column: "parent_id"
add_foreign_key "manifestations", "carrier_types"
add_foreign_key "ncid_records", "manifestations"
add_foreign_key "periodical_and_manifestations", "manifestations"
add_foreign_key "periodical_and_manifestations", "periodicals"
add_foreign_key "periodicals", "frequencies"
add_foreign_key "produces", "agents"
add_foreign_key "produces", "manifestations"
add_foreign_key "realizes", "agents"
Expand Down
14 changes: 7 additions & 7 deletions spec/fixtures/series_statements.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
one:
id: 1
id: 4d35e82d-1a19-45a1-a5e8-6dd80ae8debb
original_title: title1
position: 1
manifestation_id: 4e18e302-5f43-4edb-84c5-8b8c49ced3f6

two:
id: 2
id: e06d7f20-def7-46a9-b19d-b3095653670c
original_title: title2
title_transcription: テスト
position: 2
manifestation_id: 12955445-5083-4b29-8c39-9f2af094a696

three:
id: 3
id: 298af67f-03b8-42a1-8748-507d40e0e22b
original_title: テスト雑誌
position: 3
root_manifestation_id: a1f7f087-540c-4722-a16e-e4b26a2072fa

four:
id: 4
id: c0d6a4e9-dd3c-4833-be43-71c3366ffebc
original_title: テスト雑誌
position: 4
root_manifestation_id: 2cb759fb-0778-44d2-9aac-6c8765ccb990

five:
id: 5
id: 3de9124e-0b98-4580-98ce-f3ca4d9f0d88
original_title: テスト雑誌
position: 5
manifestation_id: ba0c94f1-860f-4e5f-b455-498d4ddcffe4
Expand All @@ -34,8 +34,8 @@ five:
#
# Table name: series_statements
#
# id :bigint(8) not null, primary key
# original_title :text
# id :uuid not null, primary key
# original_title :text not null
# numbering :text
# title_subseries :text
# numbering_subseries :text
Expand Down

0 comments on commit 1a695d3

Please sign in to comment.