WIP switching to pgsql

This commit is contained in:
nate smith 2024-04-28 00:55:33 -07:00
parent e40f12085b
commit d1c1f330c5
4 changed files with 36 additions and 7 deletions

7
initpg.sh Executable file
View File

@ -0,0 +1,7 @@
source ./pg.env
pg_ctl init
mkdir -p "$PGDATA/sockets"
echo "unix_socket_directories = 'sockets'" >> "$PGDATA/postgresql.conf"
echo "listen_addresses = ''" >> "$PGDATA/postgresql.conf"

4
pg.env Normal file
View File

@ -0,0 +1,4 @@
export PGDATA="$PWD/pgdata"
export PGHOST="$PGDATA/sockets"
export PGDATABASE="postgres"
export PGUSER="$USER"

View File

@ -1,12 +1,25 @@
CREATE TABLE IF NOT EXISTS phrases (
id INTEGER PRIMARY KEY,
sourceid INTEGER,
phrase TEXT UNIQUE,
DROP TABLE phrases;
DROP TABLE sources;
DROP TABLE CORPORA;
FOREIGN KEY (sourceid) REFERENCES sources(sourceid)
CREATE TABLE IF NOT EXISTS corpora (
id char(7) PRIMARY KEY,
name TEXT UNIQUE
);
CREATE TABLE IF NOT EXISTS sources (
id INTEGER PRIMARY KEY,
name TEXT UNIQUE
id char(7) PRIMARY KEY,
corpusid char(7) NOT NULL,
name TEXT UNIQUE,
FOREIGN KEY (corpusid) REFERENCES corpora(id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS phrases (
id SERIAL PRIMARY KEY,
sourceid char(7) NOT NULL,
phrase TEXT,
FOREIGN KEY (sourceid) REFERENCES sources(id) ON DELETE CASCADE
);

5
startpg.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
source ./pg.env
pg_ctl start