ki-backend-rs/model/sqlite3/migrations/2021-05-29-094109_initial_schema/up.sql

85 lines
2.0 KiB
MySQL
Raw Normal View History

CREATE TABLE IF NOT EXISTS user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nickname VARCHAR,
pronouns VARCHAR,
address_1_name VARCHAR,
address_2_additional VARCHAR,
address_4_street VARCHAR,
adress_house_number VARCHAR,
adress_city_code VARCHAR,
adress_country VARCHAR,
Ehrenaemter VARCHAR,
gravatar_email VARCHAR,
Freitext VARCHAR
);
CREATE TABLE IF NOT EXISTS user_skill (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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)
);
CREATE TABLE IF NOT EXISTS user_language (
id INTEGER PRIMARY KEY AUTOINCREMENT,
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)
);
CREATE TABLE IF NOT EXISTS skill (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR
);
CREATE TABLE IF NOT EXISTS user_experience (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
description VARCHAR,
start date,
end date,
FOREIGN KEY (user_id) REFERENCES user(id)
);
CREATE TABLE IF NOT EXISTS user_search_topic (
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)
);
CREATE TABLE IF NOT EXISTS user_contact (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
contact_type_id INTEGER NOT NULL,
content_ VARCHAR,
FOREIGN KEY(user_id) REFERENCES user(id),
FOREIGN KEY (contact_type_id) REFERENCES contact_types(id)
);
CREATE TABLE IF NOT EXISTS topic (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR
);
CREATE TABLE IF NOT EXISTS language (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR
);
CREATE TABLE IF NOT EXISTS experience (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR
);
CREATE TABLE IF NOT EXISTS contact_types (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR
);