Add new tables for families management
This commit is contained in:
parent
74601a8d9d
commit
e6c896efa2
@ -1,2 +1,4 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP table users;
|
||||
DROP table IF EXISTS memberships ;
|
||||
DROP table IF EXISTS families;
|
||||
DROP table IF EXISTS users;
|
@ -1,4 +1,4 @@
|
||||
-- Create table
|
||||
-- Create tables
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(30) NOT NULL,
|
||||
@ -12,4 +12,20 @@ CREATE TABLE users (
|
||||
time_activate BIGINT NOT NULL DEFAULT 0,
|
||||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
admin BOOLEAN NOT NULL DEFAULT FALSE
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE families(
|
||||
id SERIAL PRIMARY KEY,
|
||||
time_create BIGINT NOT NULL,
|
||||
name VARCHAR(30) NOT NULL,
|
||||
invitation_code VARCHAR(7) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE memberships(
|
||||
user_id integer NOT NULL REFERENCES users,
|
||||
family_id integer NOT NULL REFERENCES families,
|
||||
time_create BIGINT NOT NULL,
|
||||
is_admin BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
|
||||
PRIMARY KEY(user_id, family_id)
|
||||
);
|
@ -1,5 +1,23 @@
|
||||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
families (id) {
|
||||
id -> Int4,
|
||||
time_create -> Int8,
|
||||
name -> Varchar,
|
||||
invitation_code -> Varchar,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
memberships (user_id, family_id) {
|
||||
user_id -> Int4,
|
||||
family_id -> Int4,
|
||||
time_create -> Int8,
|
||||
is_admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
users (id) {
|
||||
id -> Int4,
|
||||
@ -16,3 +34,12 @@ diesel::table! {
|
||||
admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(memberships -> families (family_id));
|
||||
diesel::joinable!(memberships -> users (user_id));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
families,
|
||||
memberships,
|
||||
users,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user