Create tables `employees`, `employee_infos`
This commit is contained in:
parent
f174efc649
commit
4fec44f51d
|
@ -0,0 +1,6 @@
|
||||||
|
-- This file should undo anything in `up.sql`
|
||||||
|
|
||||||
|
DROP INDEX index_employee_infos_on_employee_id_and_locale;
|
||||||
|
|
||||||
|
DROP TABLE employee_infos;
|
||||||
|
DROP TABLE employees;
|
|
@ -0,0 +1,19 @@
|
||||||
|
-- Your SQL goes here
|
||||||
|
|
||||||
|
CREATE TABLE employees (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
name VARCHAR NOT NULL,
|
||||||
|
role VARCHAR NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE employee_infos (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
employee_id SERIAL NOT NULL,
|
||||||
|
locale VARCHAR NOT NULL,
|
||||||
|
name VARCHAR NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT employee_id_fk FOREIGN KEY (employee_id) REFERENCES employees(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX index_employee_infos_on_employee_id_and_locale
|
||||||
|
ON employee_infos USING btree (employee_id, locale);
|
|
@ -1,3 +1,20 @@
|
||||||
|
table! {
|
||||||
|
employee_infos (id) {
|
||||||
|
id -> Int4,
|
||||||
|
employee_id -> Int4,
|
||||||
|
locale -> Varchar,
|
||||||
|
name -> Varchar,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table! {
|
||||||
|
employees (id) {
|
||||||
|
id -> Int4,
|
||||||
|
name -> Varchar,
|
||||||
|
role -> Varchar,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
users (id) {
|
users (id) {
|
||||||
id -> Int4,
|
id -> Int4,
|
||||||
|
@ -5,3 +22,11 @@ table! {
|
||||||
encrypted_password -> Varchar,
|
encrypted_password -> Varchar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
joinable!(employee_infos -> employees (employee_id));
|
||||||
|
|
||||||
|
allow_tables_to_appear_in_same_query!(
|
||||||
|
employee_infos,
|
||||||
|
employees,
|
||||||
|
users,
|
||||||
|
);
|
||||||
|
|
Reference in New Issue