datatbase schema provisioning

This commit is contained in:
Blair Vanderlugt 2021-02-09 08:24:47 -08:00
parent d991dfdb0c
commit 7ff9b9d648
9 changed files with 17 additions and 23 deletions

View File

@ -2,6 +2,15 @@
## Getting started
### Prepare the repo
This is stuff we need to put in makefile but for now...
File mounts and permisssions need to be set
```
chmod -R 755 scripts/initdb apps/cic-meta/scripts/initdb
````
start cluster
```
docker-compose up
@ -20,6 +29,7 @@ docker-compose down -v
rebuild an images
```
docker-compose up --build <service_name>
``
```
Deployment variables are writtend to service-configs/.env after everthing is up.
Deployment variables are writtend to service-configs/.env after everthing is up.`

View File

@ -16,7 +16,7 @@ COPY cic-meta/scripts/ scripts/
RUN alias tsc=node_modules/typescript/bin/tsc
COPY cic-meta/.config/ /usr/local/etc/cic-meta/
COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql
# COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql
COPY cic-meta/docker/db.sh ./db.sh
RUN chmod 755 ./db.sh

4
apps/cic-meta/scripts/initdb/postgresql.sh Normal file → Executable file
View File

@ -1,8 +1,8 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname cic_meta <<-EOSQL
create table if not exists cic_meta.store (
psql -v ON_ERROR_STOP=1 --username grassroots --dbname cic_meta <<-EOSQL
create table if not exists store (
id serial primary key not null,
owner_fingerprint text not null,
hash char(64) not null unique,

0
apps/cic-meta/scripts/initdb/server.postgres.sql Normal file → Executable file
View File

0
apps/cic-meta/scripts/initdb/server.sql Normal file → Executable file
View File

0
apps/cic-meta/scripts/initdb/server.sqlite.sql Normal file → Executable file
View File

View File

@ -44,7 +44,7 @@ services:
# See contents of /initdb/create_db.sql for app user, password and databases
postgres:
image: postgres:10
image: postgres:12.5-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging.
# PGDATA: /tmp/cic/postgres
@ -52,8 +52,7 @@ services:
- 5432
volumes:
- ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql
# - ./apps/cic-meta/scripts/server/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
- ./scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
- ./apps/cic-meta/scripts/initdb/postgresql.sh:/docker-entrypoint-initdb.d/2-init-cic-meta.sh
- postgres-db:/var/lib/postgresql/data
redis:

0
scripts/initdb/create_db.sql Normal file → Executable file
View File

View File

@ -1,15 +0,0 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname cic_meta <<-EOSQL
create table if not exists cic_meta.store (
id serial primary key not null,
owner_fingerprint text not null,
hash char(64) not null unique,
content text not null
);
create index if not exists idx_fp on store ((lower(owner_fingerprint)));
EOSQL