cavecomm/setupdb.sh

81 lines
2.1 KiB
Bash

#!/bin/sh
sudo -u postgres createuser -P -e cavecomm
sudo -u postgres createdb --owner=cavecomm cavecomm 'contains all the information for the cavecomm instance on this device'
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE cavecomm TO cavecomm;"
sudo -u postgres psql -c "CREATE TABLE requests(
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
customerName text,
customerEmailAddress text,
customerContactDetails text,
freelancerID INT,
templateID INT,
currencyPreference varchar(6),
priceUpFront decimal,
priceOnDeliver decimal,
requestDescription text,
accepted boolean,
upFrontInvoiceID text,
onDeliverInvoiceID text,
upFrontPaid boolean,
onDeliverPaid boolean,
completed boolean
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE freelancers(
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
emailAddress text UNIQUE NOT NULL,
salt text NOT NULL,
hash text NOT NULL,
name text,
generalInformation text,
basicInformation text,
stripeAccountInformation text,
commissionLimit int,
loginValidationKey text
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE templates(
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
freelancerID int,
name text NOT NULL,
content text,
contactData text,
contactInformation text,
currencyPreference text,
priceUpFront decimal,
priceOnDeliver decimal,
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE cryptoWallets(
id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
freelancerID int,
name text,
walletAddress text
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE passwordResetKeys(
freelancerEmail text PRIMARY KEY,
passwordResetKey text UNIQUE,
expiration timestamp
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE loginLockOut(
email text PRIMARY KEY,
attempts int,
expiration timestamp
);
" cavecomm
sudo -u postgres psql -c "CREATE TABLE aliasRoutes(
aliasName text PRIMARY KEY,
freelancerID int,
route text,
routeParameters text
);
" cavecomm