From 5aebc32e870538cfae5ff5ad66c1915144ad8268 Mon Sep 17 00:00:00 2001 From: Gulliver Date: Sun, 30 May 2021 23:20:55 +0200 Subject: [PATCH] fixed table names on FOREIGN KEY references (should also use plurals as tables was renamed) --- .../2021-05-29-094109_initial_schema/up.sql | 16 ++++++++-------- model/sqlite3/src/db/schema.rs | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/model/sqlite3/migrations/2021-05-29-094109_initial_schema/up.sql b/model/sqlite3/migrations/2021-05-29-094109_initial_schema/up.sql index dd56c3f..3032dd2 100644 --- a/model/sqlite3/migrations/2021-05-29-094109_initial_schema/up.sql +++ b/model/sqlite3/migrations/2021-05-29-094109_initial_schema/up.sql @@ -18,8 +18,8 @@ CREATE TABLE IF NOT EXISTS user_skills ( user_id INTEGER NOT NULL, skill_id INTEGER OT NULL, level INTEGER, - FOREIGN KEY(user_id) REFERENCES user(id), - FOREIGN KEY(skill_id) REFERENCES skill(id) + FOREIGN KEY(user_id) REFERENCES users(id), + FOREIGN KEY(skill_id) REFERENCES skills(id) ); CREATE TABLE IF NOT EXISTS user_languages ( @@ -28,8 +28,8 @@ CREATE TABLE IF NOT EXISTS user_languages ( user_id INTEGER NOT NULL, language_id INTEGER NOT NULL, level INTEGER, - FOREIGN KEY(user_id) REFERENCES user(id), - FOREIGN KEY(language_id) REFERENCES language(id) + FOREIGN KEY(user_id) REFERENCES users(id), + FOREIGN KEY(language_id) REFERENCES languages(id) ); CREATE TABLE IF NOT EXISTS skills ( @@ -43,15 +43,15 @@ CREATE TABLE IF NOT EXISTS user_experiences ( description VARCHAR, start date, end date, - FOREIGN KEY (user_id) REFERENCES user(id) + FOREIGN KEY (user_id) REFERENCES users(id) ); CREATE TABLE IF NOT EXISTS user_search_topics ( id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, topic_id INTEGER NOT NULL, - FOREIGN KEY (user_id) REFERENCES user(id), - FOREIGN KEY (topic_id) REFERENCES topic(id) + FOREIGN KEY (user_id) REFERENCES users(id), + FOREIGN KEY (topic_id) REFERENCES topics(id) ); CREATE TABLE IF NOT EXISTS user_contacts ( @@ -59,7 +59,7 @@ CREATE TABLE IF NOT EXISTS user_contacts ( user_id INTEGER NOT NULL, contact_type_id INTEGER NOT NULL, content_ VARCHAR, - FOREIGN KEY(user_id) REFERENCES user(id), + FOREIGN KEY(user_id) REFERENCES users(id), FOREIGN KEY (contact_type_id) REFERENCES contact_types(id) ); diff --git a/model/sqlite3/src/db/schema.rs b/model/sqlite3/src/db/schema.rs index 1725a6b..f5de5e0 100644 --- a/model/sqlite3/src/db/schema.rs +++ b/model/sqlite3/src/db/schema.rs @@ -96,6 +96,14 @@ table! { } joinable!(user_contacts -> contact_types (contact_type_id)); +joinable!(user_contacts -> users (user_id)); +joinable!(user_experiences -> users (user_id)); +joinable!(user_languages -> languages (language_id)); +joinable!(user_languages -> users (user_id)); +joinable!(user_search_topics -> topics (topic_id)); +joinable!(user_search_topics -> users (user_id)); +joinable!(user_skills -> skills (skill_id)); +joinable!(user_skills -> users (user_id)); allow_tables_to_appear_in_same_query!( contact_types,