Skip to content

Commit

Permalink
use uuid as primary key for NewsFeed and NewsPost
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Mar 11, 2019
1 parent af3849f commit 0183126
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/models/news_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def self.fetch_feeds
#
# Table name: news_feeds
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# library_group_id :integer default(1), not null
# title :string
# url :string
Expand Down
2 changes: 1 addition & 1 deletion app/models/news_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def check_date
#
# Table name: news_posts
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# title :text
# body :text
# user_id :bigint(8) not null
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20081031033632_create_news_feeds.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateNewsFeeds < ActiveRecord::Migration[5.2]
def change
create_table :news_feeds do |t|
create_table :news_feeds, id: :uuid do |t|
t.integer :library_group_id, default: 1, null: false
t.string :title
t.string :url
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20090126071155_create_news_posts.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateNewsPosts < ActiveRecord::Migration[5.2]
def change
create_table :news_posts do |t|
create_table :news_posts, id: :uuid do |t|
t.text :title
t.text :body
t.references :user, foreign_key: true, null: false
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 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,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
Expand Up @@ -2,7 +2,7 @@ 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_merge_list, foreign_key: true, index: false, null: false, type: :uuid

t.timestamps
end
Expand Down
12 changes: 0 additions & 12 deletions spec/dummy/db/migrate/20150421023923_create_identities.rb

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20190102034126_create_doi_records.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CreateDoiRecords < ActiveRecord::Migration[5.2]
def change
create_table :doi_records do |t|
create_table :doi_records, id: :uuid do |t|
t.string :body, index: {unique: true}, null: false
t.string :display_body, null: false
t.string :source
Expand Down
29 changes: 8 additions & 21 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
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 @@ -277,7 +277,7 @@
t.index ["work_id"], name: "index_creates_on_work_id"
end

create_table "doi_records", force: :cascade do |t|
create_table "doi_records", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "body", null: false
t.string "display_body", null: false
t.string "source"
Expand Down Expand Up @@ -339,19 +339,6 @@
t.index ["manifestation_id"], name: "index_identifiers_on_manifestation_id"
end

create_table "identities", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "password_digest"
t.uuid "profile_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "provider"
t.index ["email"], name: "index_identities_on_email"
t.index ["name"], name: "index_identities_on_name"
t.index ["profile_id"], name: "index_identities_on_profile_id"
end

create_table "import_request_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}
Expand All @@ -365,7 +352,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 @@ -614,7 +601,7 @@
t.datetime "updated_at", null: false
end

create_table "news_feeds", force: :cascade do |t|
create_table "news_feeds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.integer "library_group_id", default: 1, null: false
t.string "title"
t.string "url"
Expand All @@ -624,7 +611,7 @@
t.datetime "updated_at", null: false
end

create_table "news_posts", force: :cascade do |t|
create_table "news_posts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.text "title"
t.text "body"
t.bigint "user_id", null: false
Expand Down Expand Up @@ -831,15 +818,15 @@
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_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"
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/news_feeds.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
news_feed_00001:
id: 1
id: 2c2c2c68-7214-43b0-a978-15a5c0bcdce6
title: NDL
url: http://iss.ndl.go.jp/information/feed/
position: 1

news_feed_00002:
id: 2
id: 09ab79aa-4be7-4daf-8449-18341051a608
title: invalid feed
url: http://example.com/invalid_feed
position: 2
Expand All @@ -14,7 +14,7 @@ news_feed_00002:
#
# Table name: news_feeds
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# library_group_id :integer default(1), not null
# title :string
# url :string
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/news_posts.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
news_post_00001:
id: 1
id: a1d0d5ab-e277-4a77-b79a-4e4a97370428
title: お知らせ
body: お知らせの内容
user_id: 1
position: 1

news_post_00002:
id: 2
id: 2865efc0-e79c-402c-ad09-970ff6e0a934
title: お知らせ
body: お知らせの内容
user_id: 1
Expand All @@ -16,7 +16,7 @@ news_post_00002:
#
# Table name: news_posts
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# title :text
# body :text
# user_id :bigint(8) not null
Expand Down
2 changes: 1 addition & 1 deletion spec/models/news_feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#
# Table name: news_feeds
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# library_group_id :integer default(1), not null
# title :string
# url :string
Expand Down
2 changes: 1 addition & 1 deletion spec/models/news_post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Table name: news_posts
#
# id :bigint(8) not null, primary key
# id :uuid not null, primary key
# title :text
# body :text
# user_id :bigint(8) not null
Expand Down

0 comments on commit 0183126

Please sign in to comment.