Commit 042934f2 authored by Jon Tavernier's avatar Jon Tavernier

create resuable backends

parent 9b5d1d04
# Backend Stuff
The purpose of these services is to standup re-usable backends. Other tools can join the same network to interact with these backends.
Network name: `jon-backend`
Join with...
```yaml
some-service:
networks:
- jon-backend
networks:
jon-backend:
external: true
```
version: '3.7'
services:
db-postgres:
build: ./postgres/
expose:
- "5432"
environment:
POSTGRES_PASSWORD: blah
networks:
- "jon-backend"
db-mysql:
build: ./mysql/
expose:
- "3306"
environment:
MYSQL_ROOT_PASSWORD: blah
networks:
- "jon-backend"
networks:
jon-backend:
driver: bridge
name: jon-backend
\ No newline at end of file
#! /usr/bin/env bash
docker-compose down
FROM mysql:8.0.15
# files placed here will run in alphabetical order on container launch
COPY ./sql /docker-entrypoint-initdb.d
use app;
create table app.users (
user_id int auto_increment comment 'Primary Key. Meaningless value to the business.',
name text comment 'User name as entered by the user.',
created_at timestamp comment 'Date row was created. Not for business use.',
deleted_at timestamp comment 'Date row was deleted. Not for business use.',
updated_at timestamp comment 'Date row was updated. Not for business use.',
constraint pk_users primary key (user_id)
)
comment = 'People who have registered on our site.'
;
insert into app.users(name, created_at, updated_at)
values
('Jon', '2018-07-19 14:00:00', '2018-07-19 14:00:00'),
('Garrett', '2018-07-10 14:00:00', '2018-07-19 14:00:00');
FROM postgres:11-alpine
# files placed here will run in alphabetical order on container launch
COPY ./sql /docker-entrypoint-initdb.d
create table app.users (
user_id serial,
name text,
created_at timestamptz,
deleted_at timestamptz,
updated_at timestamptz,
constraint pk_users primary key (user_id)
);
insert into app.users(name, created_at, updated_at)
values
('Jon', '2018-07-19 14:00:00', '2018-07-19 14:00:00'),
('Garrett', '2018-07-10 14:00:00', '2018-07-19 14:00:00');
comment on table app.users is 'People who have registered on our site.';
comment on column app.users.user_id is 'Primary Key. Meaningless value to the business.';
comment on column app.users.name is 'User name as entered by the user.';
comment on column app.users.created_at is 'Date row was created. Not for business use.';
comment on column app.users.deleted_at is 'Date row was deleted. Not for business use.';
comment on column app.users.updated_at is 'Date row was updated. Not for business use.';
create table orders (
create table app.orders (
order_id integer,
order_number varchar(20) not null,
amount_paid integer not null,
......@@ -7,8 +7,8 @@ create table orders (
constraint uq_orders_order_number unique (order_number)
);
comment on table orders is 'Purchases made by buyers.';
comment on column orders.order_id is 'Primary Key. Meaningless value to the business.';
comment on column orders.order_number is 'Order Number. Public ID for this order. Can share with other systems.';
comment on column orders.amount_paid is 'Amount paid by buyer in USD cents.';
comment on column orders.product_category is 'Product Category to which this purchase belongs.';
comment on table app.orders is 'Purchases made by buyers.';
comment on column app.orders.order_id is 'Primary Key. Meaningless value to the business.';
comment on column app.orders.order_number is 'Order Number. Public ID for this order. Can share with other systems.';
comment on column app.orders.amount_paid is 'Amount paid by buyer in USD cents.';
comment on column app.orders.product_category is 'Product Category to which this purchase belongs.';
insert into orders(
insert into app.orders(
order_id,
order_number,
amount_paid,
......
create index ix_orders_product_category on app.orders(product_category);
create index ix_orders_order_number on app.orders(order_number);
#! /usr/bin/env bash
docker-compose up --force --build --detach
......@@ -6,16 +6,20 @@ I played around with Metabase for an hour. It made an excellent first impressio
## First Time Setup
- Start the backend databases.
- `../backend/up.sh`
- Launch `./docker-compose.yaml`.
- Metabase will launch plus other random data stores I add for testing purposes.
- `docker-compose up --build --force`
- Visit `http://localhost:3000`.
- Create my account.
- Add the Postgres database.
- Name: `Purchases`
- Host: `postgres`
- Host: `db-postgres`
- Port: `5432`
- DB: `postgres`
- User: `postgres`
- Password: `testing`
- Password: `blah`
- I like the option of choosing what syncs and when. I opted not to do that for now though.
- Disable anonymous stats.
......@@ -27,7 +31,7 @@ I played around with Metabase for an hour. It made an excellent first impressio
## Using Metabase
- After logging in, I see "Purchases" under "Our Data".
- After logging in, I see "Users" and "Orders" under "Our Data".
- I see options for X-ray on the Orders table, which shows me 50,000 total transactions. It auto discovered the product category table too and permitted me to drill-down to see aggregate counts on that field.
- Metabase shows the table comment I added in Postgres. The columns comments do not appear.
- Metabase is making an excellent first impression!
......
......@@ -13,11 +13,8 @@ services:
# i'm just testing. this is a horrible decision for production.
MB_PASSWORD_COMPLEXITY: weak
MB_PASSWORD_LENGTH: 1
postgres:
image: postgres:11-alpine
expose:
- "5432"
environment:
POSTGRES_PASSWORD: testing
volumes:
- ./postgres:/docker-entrypoint-initdb.d:ro
networks:
- jon-backend
networks:
jon-backend:
external: true
\ No newline at end of file
2018-12-08 17:34:31 jdbc[4]: exception
2019-04-02 13:37:25 jdbc[4]: exception
org.h2.jdbc.JdbcSQLException: Table "DATABASECHANGELOGLOCK" not found; SQL statement:
SELECT COUNT(*) FROM PUBLIC.DATABASECHANGELOGLOCK [42102-197]
create index ix_orders_product_category on orders(product_category);
create index ix_orders_order_number on orders(order_number);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment