Skip to content

Commit cf7c942

Browse files
committed
Modernized Postgres setup (mostly db/init_sql.sh)
1 parent 5de7432 commit cf7c942

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
*~
2+
*.swp
3+
*.swo
14
.env
25
pursuemail

db/init_sql.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fi
99
source ../.env
1010
psql -d postgres -c "CREATE USER pursuemail WITH PASSWORD '$PGPASSWORD';" || true
1111
psql -d postgres -f sql/pre.sql
12+
export PGHOST=localhost
1213
export PGUSER=pursuemail
1314
export PGDATABASE=pursuemail
1415

@@ -21,4 +22,4 @@ for file in sql/table*.sql; do
2122
psql -f "$file"
2223
done
2324

24-
/bin/bash migrate.sh
25+
/bin/bash migrate.sh sql/migration*.sql

db/migrate.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set -euo pipefail
22

3+
export PGHOST=localhost
34
export PGUSER=postgres
45
export PGDATABASE=pursuemail
56
if [ "`uname -s`" != "Linux" ]; then
@@ -8,6 +9,6 @@ if [ "`uname -s`" != "Linux" ]; then
89
fi
910

1011
# Run migrations
11-
for file in sql/migration*.sql; do
12+
for file in $*; do
1213
psql -f "$file"
1314
done

db/sql/init001.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
create extension if not exists "uuid-ossp";
22
CREATE TABLE email_account (
3-
id uuid NOT NULL UNIQUE PRIMARY KEY DEFAULT uuid_generate_v4(),
3+
id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(),
44
email text NOT NULL,
55
created timestamp WITH time zone DEFAULT now()
66
);

0 commit comments

Comments
 (0)