Add new tables for families management
This commit is contained in:
@ -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)
|
||||
);
|
Reference in New Issue
Block a user