Skip to content

Commit da9602e

Browse files
committed
On #736 adapted migratons and schema to rails 5
1 parent a475bb9 commit da9602e

3 files changed

+110
-7
lines changed

db/migrate/20200718074330_delete_orphaned_records_from_all_tables.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DeleteOrphanedRecordsFromAllTables < ActiveRecord::Migration
1+
class DeleteOrphanedRecordsFromAllTables < ActiveRecord::Migration[5.2]
22
class Article < ActiveRecord::Base; end
33
class ArticleCategory < ActiveRecord::Base; end
44
class ArticlePrice < ActiveRecord::Base; end

db/migrate/20200718074332_add_foreign_keys_to_all_tables.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddForeignKeysToAllTables < ActiveRecord::Migration
1+
class AddForeignKeysToAllTables < ActiveRecord::Migration[5.2]
22
def change
33
# article_prices
44
add_foreign_key :article_prices, :articles
@@ -15,9 +15,9 @@ def change
1515
add_foreign_key :bank_transactions, :bank_accounts
1616
add_foreign_key :bank_transactions, :financial_links
1717

18-
# deliveries
19-
add_foreign_key :deliveries, :suppliers
20-
add_foreign_key :deliveries, :invoices
18+
# stock_events
19+
add_foreign_key :stock_events, :suppliers
20+
add_foreign_key :stock_events, :invoices
2121

2222
# documents
2323
add_foreign_key :documents, :users, column: :created_by_user_id
@@ -119,10 +119,9 @@ def change
119119
add_foreign_key :printer_jobs, :users, column: :finished_by_user_id
120120

121121
# stock_changes
122-
add_foreign_key :stock_changes, :deliveries
122+
add_foreign_key :stock_changes, :stock_events
123123
add_foreign_key :stock_changes, :orders
124124
add_foreign_key :stock_changes, :articles, column: :stock_article_id
125-
add_foreign_key :stock_changes, :stock_takings
126125

127126
# supplier_categories
128127
add_foreign_key :supplier_categories, :financial_transaction_classes

db/schema.rb

+104
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
t.integer "user_id", default: 0, null: false
5959
t.integer "task_id", default: 0, null: false
6060
t.boolean "accepted", default: false
61+
t.index ["task_id"], name: "fk_rails_b7c53ee3b6"
6162
t.index ["user_id", "task_id"], name: "index_assignments_on_user_id_and_task_id", unique: true
6263
end
6364

@@ -81,6 +82,7 @@
8182
t.text "receipt"
8283
t.binary "image", limit: 16777215
8384
t.integer "financial_link_id"
85+
t.index ["bank_account_id"], name: "fk_rails_e0117c6727"
8486
t.index ["financial_link_id"], name: "index_bank_transactions_on_financial_link_id"
8587
end
8688

@@ -92,6 +94,7 @@
9294
t.datetime "created_at"
9395
t.datetime "updated_at"
9496
t.integer "parent_id"
97+
t.index ["created_by_user_id"], name: "fk_rails_7294a1aa59"
9598
t.index ["parent_id"], name: "index_documents_on_parent_id"
9699
end
97100

@@ -108,6 +111,7 @@
108111
t.integer "financial_transaction_class_id", null: false
109112
t.string "name_short"
110113
t.integer "bank_account_id"
114+
t.index ["financial_transaction_class_id"], name: "fk_rails_f2b646cddc"
111115
t.index ["name_short"], name: "index_financial_transaction_types_on_name_short"
112116
end
113117

@@ -121,8 +125,12 @@
121125
t.integer "financial_link_id"
122126
t.integer "reverts_id"
123127
t.integer "group_order_id"
128+
t.index ["financial_link_id"], name: "fk_rails_d41d3fdfae"
129+
t.index ["financial_transaction_type_id"], name: "fk_rails_dba6d95fbf"
130+
t.index ["group_order_id"], name: "fk_rails_88ae0ba39c"
124131
t.index ["ordergroup_id"], name: "index_financial_transactions_on_ordergroup_id"
125132
t.index ["reverts_id"], name: "index_financial_transactions_on_reverts_id", unique: true
133+
t.index ["user_id"], name: "fk_rails_0cbb08eeee"
126134
end
127135

128136
create_table "group_order_article_quantities", id: :integer, force: :cascade do |t|
@@ -157,6 +165,7 @@
157165
t.index ["order_id"], name: "index_group_orders_on_order_id"
158166
t.index ["ordergroup_id", "order_id"], name: "index_group_orders_on_ordergroup_id_and_order_id", unique: true
159167
t.index ["ordergroup_id"], name: "index_group_orders_on_ordergroup_id"
168+
t.index ["updated_by_user_id"], name: "fk_rails_1889c54304"
160169
end
161170

162171
create_table "groups", id: :integer, force: :cascade do |t|
@@ -190,7 +199,9 @@
190199
t.integer "group_id", default: 0, null: false
191200
t.integer "user_id", default: 0, null: false
192201
t.string "email", default: "", null: false
202+
t.index ["group_id"], name: "fk_rails_9e216f1ff4"
193203
t.index ["token"], name: "index_invites_on_token"
204+
t.index ["user_id"], name: "fk_rails_ff69dbb2ac"
194205
end
195206

196207
create_table "invoices", id: :integer, force: :cascade do |t|
@@ -208,6 +219,8 @@
208219
t.string "attachment_mime"
209220
t.binary "attachment_data", limit: 16777215
210221
t.integer "financial_link_id"
222+
t.index ["created_by_user_id"], name: "fk_rails_8fd25eeb3c"
223+
t.index ["financial_link_id"], name: "fk_rails_75b0aafe67"
211224
t.index ["supplier_id"], name: "index_invoices_on_supplier_id"
212225
end
213226

@@ -231,6 +244,7 @@
231244
create_table "memberships", id: :integer, force: :cascade do |t|
232245
t.integer "group_id", default: 0, null: false
233246
t.integer "user_id", default: 0, null: false
247+
t.index ["group_id"], name: "fk_rails_aaf389f138"
234248
t.index ["user_id", "group_id"], name: "index_memberships_on_user_id_and_group_id", unique: true
235249
end
236250

@@ -253,6 +267,9 @@
253267
t.integer "group_id"
254268
t.string "salt"
255269
t.binary "received_email", limit: 16777215
270+
t.index ["group_id"], name: "fk_rails_841b0ae6ac"
271+
t.index ["reply_to"], name: "fk_rails_3730b06fab"
272+
t.index ["sender_id"], name: "fk_rails_b8f26a382d"
256273
end
257274

258275
create_table "oauth_access_grants", id: :integer, force: :cascade do |t|
@@ -303,6 +320,8 @@
303320
t.integer "article_price_id"
304321
t.integer "units_billed"
305322
t.integer "units_received"
323+
t.index ["article_id"], name: "fk_rails_44e6c21781"
324+
t.index ["article_price_id"], name: "fk_rails_798fa38c22"
306325
t.index ["order_id", "article_id"], name: "index_order_articles_on_order_id_and_article_id", unique: true
307326
t.index ["order_id"], name: "index_order_articles_on_order_id"
308327
end
@@ -313,6 +332,7 @@
313332
t.text "text"
314333
t.datetime "created_at"
315334
t.index ["order_id"], name: "index_order_comments_on_order_id"
335+
t.index ["user_id"], name: "fk_rails_9db67cf94d"
316336
end
317337

318338
create_table "orders", id: :integer, force: :cascade do |t|
@@ -331,7 +351,11 @@
331351
t.datetime "last_sent_mail"
332352
t.integer "end_action", default: 0, null: false
333353
t.decimal "transport", precision: 8, scale: 2
354+
t.index ["created_by_user_id"], name: "fk_rails_30144627f8"
355+
t.index ["invoice_id"], name: "fk_rails_b33ed6c672"
334356
t.index ["state"], name: "index_orders_on_state"
357+
t.index ["supplier_id"], name: "fk_rails_d426350910"
358+
t.index ["updated_by_user_id"], name: "fk_rails_f3fe5911c4"
335359
end
336360

337361
create_table "page_versions", id: :integer, force: :cascade do |t|
@@ -343,6 +367,7 @@
343367
t.integer "parent_id"
344368
t.datetime "updated_at"
345369
t.index ["page_id"], name: "index_page_versions_on_page_id"
370+
t.index ["parent_id"], name: "fk_rails_966d369f50"
346371
end
347372

348373
create_table "pages", id: :integer, force: :cascade do |t|
@@ -355,6 +380,7 @@
355380
t.integer "parent_id"
356381
t.datetime "created_at"
357382
t.datetime "updated_at"
383+
t.index ["parent_id"], name: "fk_rails_409bbac70a"
358384
t.index ["permalink"], name: "index_pages_on_permalink"
359385
t.index ["title"], name: "index_pages_on_title"
360386
end
@@ -379,7 +405,9 @@
379405
t.text "note"
380406
t.datetime "created_at"
381407
t.datetime "updated_at"
408+
t.index ["ordergroup_id"], name: "fk_rails_931f43cfec"
382409
t.index ["poll_id", "user_id", "ordergroup_id"], name: "index_poll_votes_on_poll_id_and_user_id_and_ordergroup_id", unique: true
410+
t.index ["user_id"], name: "fk_rails_b64de9b025"
383411
end
384412

385413
create_table "polls", id: :integer, force: :cascade do |t|
@@ -399,6 +427,7 @@
399427
t.integer "max_points"
400428
t.datetime "created_at"
401429
t.datetime "updated_at"
430+
t.index ["created_by_user_id"], name: "fk_rails_ddedb38d1d"
402431
t.index ["final_choice"], name: "index_polls_on_final_choice"
403432
end
404433

@@ -416,7 +445,10 @@
416445
t.integer "created_by_user_id", null: false
417446
t.integer "finished_by_user_id"
418447
t.datetime "finished_at"
448+
t.index ["created_by_user_id"], name: "fk_rails_a222b5a8b4"
419449
t.index ["finished_at"], name: "index_printer_jobs_on_finished_at"
450+
t.index ["finished_by_user_id"], name: "fk_rails_c259d78e0a"
451+
t.index ["order_id"], name: "fk_rails_f691a1be68"
420452
end
421453

422454
create_table "settings", id: :integer, force: :cascade do |t|
@@ -435,6 +467,7 @@
435467
t.integer "stock_article_id"
436468
t.integer "quantity", default: 0
437469
t.datetime "created_at"
470+
t.index ["order_id"], name: "fk_rails_6ddf028707"
438471
t.index ["stock_article_id"], name: "index_stock_changes_on_stock_article_id"
439472
t.index ["stock_event_id"], name: "index_stock_changes_on_stock_event_id"
440473
end
@@ -446,13 +479,15 @@
446479
t.text "note"
447480
t.integer "invoice_id"
448481
t.string "type", null: false
482+
t.index ["invoice_id"], name: "fk_rails_04a623ff69"
449483
t.index ["supplier_id"], name: "index_stock_events_on_supplier_id"
450484
end
451485

452486
create_table "supplier_categories", id: :integer, force: :cascade do |t|
453487
t.string "name", null: false
454488
t.string "description"
455489
t.integer "financial_transaction_class_id"
490+
t.index ["financial_transaction_class_id"], name: "fk_rails_e4db9d9002"
456491
end
457492

458493
create_table "suppliers", id: :integer, force: :cascade do |t|
@@ -475,6 +510,8 @@
475510
t.string "iban"
476511
t.integer "supplier_category_id"
477512
t.index ["name"], name: "index_suppliers_on_name", unique: true
513+
t.index ["shared_supplier_id"], name: "fk_rails_6958f49bbb"
514+
t.index ["supplier_category_id"], name: "fk_rails_f8fa27fa1f"
478515
end
479516

480517
create_table "tasks", id: :integer, force: :cascade do |t|
@@ -489,8 +526,10 @@
489526
t.integer "duration", default: 1
490527
t.integer "periodic_task_group_id"
491528
t.integer "created_by_user_id"
529+
t.index ["created_by_user_id"], name: "fk_rails_1f562c7b99"
492530
t.index ["due_date"], name: "index_tasks_on_due_date"
493531
t.index ["name"], name: "index_tasks_on_name"
532+
t.index ["periodic_task_group_id"], name: "fk_rails_78a5d11f82"
494533
t.index ["workgroup_id"], name: "index_tasks_on_workgroup_id"
495534
end
496535

@@ -513,4 +552,69 @@
513552
t.index ["nick"], name: "index_users_on_nick", unique: true
514553
end
515554

555+
add_foreign_key "article_prices", "articles"
556+
add_foreign_key "articles", "article_categories"
557+
add_foreign_key "articles", "suppliers"
558+
add_foreign_key "assignments", "tasks"
559+
add_foreign_key "assignments", "users"
560+
add_foreign_key "bank_transactions", "bank_accounts"
561+
add_foreign_key "bank_transactions", "financial_links"
562+
add_foreign_key "documents", "users", column: "created_by_user_id"
563+
add_foreign_key "financial_transaction_types", "financial_transaction_classes"
564+
add_foreign_key "financial_transactions", "financial_links"
565+
add_foreign_key "financial_transactions", "financial_transaction_types"
566+
add_foreign_key "financial_transactions", "financial_transactions", column: "reverts_id"
567+
add_foreign_key "financial_transactions", "group_orders"
568+
add_foreign_key "financial_transactions", "groups", column: "ordergroup_id"
569+
add_foreign_key "financial_transactions", "users"
570+
add_foreign_key "group_order_article_quantities", "group_order_articles"
571+
add_foreign_key "group_order_articles", "group_orders"
572+
add_foreign_key "group_order_articles", "order_articles"
573+
add_foreign_key "group_orders", "groups", column: "ordergroup_id"
574+
add_foreign_key "group_orders", "orders"
575+
add_foreign_key "group_orders", "users", column: "updated_by_user_id"
576+
add_foreign_key "invites", "groups"
577+
add_foreign_key "invites", "users"
578+
add_foreign_key "invoices", "financial_links"
579+
add_foreign_key "invoices", "suppliers"
580+
add_foreign_key "invoices", "users", column: "created_by_user_id"
581+
add_foreign_key "memberships", "groups"
582+
add_foreign_key "memberships", "users"
583+
add_foreign_key "message_recipients", "messages"
584+
add_foreign_key "message_recipients", "users"
585+
add_foreign_key "messages", "groups"
586+
add_foreign_key "messages", "messages", column: "reply_to"
587+
add_foreign_key "messages", "users", column: "sender_id"
588+
add_foreign_key "order_articles", "article_prices"
589+
add_foreign_key "order_articles", "articles"
590+
add_foreign_key "order_articles", "orders"
591+
add_foreign_key "order_comments", "orders"
592+
add_foreign_key "order_comments", "users"
593+
add_foreign_key "orders", "invoices"
594+
add_foreign_key "orders", "suppliers"
595+
add_foreign_key "orders", "users", column: "created_by_user_id"
596+
add_foreign_key "orders", "users", column: "updated_by_user_id"
597+
add_foreign_key "page_versions", "pages"
598+
add_foreign_key "page_versions", "pages", column: "parent_id"
599+
add_foreign_key "pages", "pages", column: "parent_id"
600+
add_foreign_key "poll_choices", "poll_votes"
601+
add_foreign_key "poll_votes", "groups", column: "ordergroup_id"
602+
add_foreign_key "poll_votes", "polls"
603+
add_foreign_key "poll_votes", "users"
604+
add_foreign_key "polls", "users", column: "created_by_user_id"
605+
add_foreign_key "printer_job_updates", "printer_jobs"
606+
add_foreign_key "printer_jobs", "orders"
607+
add_foreign_key "printer_jobs", "users", column: "created_by_user_id"
608+
add_foreign_key "printer_jobs", "users", column: "finished_by_user_id"
609+
add_foreign_key "stock_changes", "articles", column: "stock_article_id"
610+
add_foreign_key "stock_changes", "orders"
611+
add_foreign_key "stock_changes", "stock_events"
612+
add_foreign_key "stock_events", "invoices"
613+
add_foreign_key "stock_events", "suppliers"
614+
add_foreign_key "supplier_categories", "financial_transaction_classes"
615+
add_foreign_key "suppliers", "supplier_categories"
616+
add_foreign_key "suppliers", "suppliers", column: "shared_supplier_id"
617+
add_foreign_key "tasks", "groups", column: "periodic_task_group_id"
618+
add_foreign_key "tasks", "groups", column: "workgroup_id"
619+
add_foreign_key "tasks", "users", column: "created_by_user_id"
516620
end

0 commit comments

Comments
 (0)