Skip to content

Instantly share code, notes, and snippets.

@noudadrichem
Created June 16, 2019 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noudadrichem/dc91f1b3e5cea84bd8f9e3b15218a287 to your computer and use it in GitHub Desktop.
Save noudadrichem/dc91f1b3e5cea84bd8f9e3b15218a287 to your computer and use it in GitHub Desktop.
-- delete
drop table message;
drop table email;
drop table product;
drop table feed;
drop table account;
create table account (
account_id SERIAL PRIMARY KEY not null,
name varchar(255) not null,
password varchar(255) not null,
email_adress varchar(255) not null,
role varchar(255) not null
);
create table feed (
feed_id varchar(255) PRIMARY KEY not null,
title varchar(255) not null,
description varchar(255),
feed_link varchar(255) not null,
publication_date varchar(255)
);
create table product (
product_id SERIAL PRIMARY KEY not null,
hashed varchar(255) not null
);
create table message (
message_id SERIAL PRIMARY KEY not null,
title varchar(255) not null,
description varchar(255),
email_adress varchar(255) not null,
publication_date Date not null,
type varchar(8) not null
);
create table email (
email_id SERIAL PRIMARY KEY not null,
email_address varchar(255) not null,
name varchar(255)
);
alter table product ADD COLUMN feed_id varchar(255);
alter table product ADD CONSTRAINT feedForeignKey FOREIGN KEY (feed_id) REFERENCES feed (feed_id);
alter table feed ADD COLUMN account_id int;
alter table feed ADD CONSTRAINT feedAccountKey FOREIGN KEY (account_id) REFERENCES account(account_id);
alter table message ADD COLUMN feed_id varchar(255);
alter table message ADD CONSTRAINT feedIdMessage FOREIGN KEY (feed_id) REFERENCES feed(feed_id);
alter table email ADD COLUMN feed_id varchar(255);
alter table email ADD CONSTRAINT feedIdEmail FOREIGN KEY (feed_id) REFERENCES feed(feed_id);
-- first account
insert into account(name, password, email_adress, role) values ('noud', 'test1234', 'noud@bannerwise.io', 'admin');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment