mirror of https://github.com/Budibase/budibase.git
Browse Source
Allow SQL many to many relationships to use arbitrarily named columns in junction tablepull/2881/head
committed by
GitHub
8 changed files with 107 additions and 9 deletions
@ -0,0 +1,28 @@ |
|||
version: "3.8" |
|||
services: |
|||
db: |
|||
container_name: postgres |
|||
image: postgres |
|||
restart: always |
|||
environment: |
|||
POSTGRES_USER: root |
|||
POSTGRES_PASSWORD: root |
|||
POSTGRES_DB: main |
|||
ports: |
|||
- "5432:5432" |
|||
volumes: |
|||
#- pg_data:/var/lib/postgresql/data/ |
|||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql |
|||
|
|||
pgadmin: |
|||
container_name: pgadmin-pg |
|||
image: dpage/pgadmin4 |
|||
restart: always |
|||
environment: |
|||
PGADMIN_DEFAULT_EMAIL: root@root.com |
|||
PGADMIN_DEFAULT_PASSWORD: root |
|||
ports: |
|||
- "5050:80" |
|||
|
|||
#volumes: |
|||
# pg_data: |
|||
@ -0,0 +1,41 @@ |
|||
SELECT 'CREATE DATABASE main' |
|||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'main')\gexec |
|||
|
|||
CREATE TABLE categories |
|||
( |
|||
name text COLLATE pg_catalog."default", |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
CONSTRAINT categories_pkey PRIMARY KEY (id) |
|||
); |
|||
|
|||
CREATE TABLE customers |
|||
( |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
name text COLLATE pg_catalog."default", |
|||
email text COLLATE pg_catalog."default", |
|||
age integer, |
|||
"dateOfBirth" date, |
|||
CONSTRAINT customers_pkey PRIMARY KEY (id) |
|||
); |
|||
|
|||
CREATE TABLE customer_category |
|||
( |
|||
customer_id integer, |
|||
category_id integer, |
|||
notes text COLLATE pg_catalog."default", |
|||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), |
|||
CONSTRAINT "Category" FOREIGN KEY (category_id) |
|||
REFERENCES public.categories (id) MATCH SIMPLE |
|||
ON UPDATE NO ACTION |
|||
ON DELETE NO ACTION |
|||
NOT VALID, |
|||
CONSTRAINT "Customer" FOREIGN KEY (customer_id) |
|||
REFERENCES public.customers (id) MATCH SIMPLE |
|||
ON UPDATE NO ACTION |
|||
ON DELETE NO ACTION |
|||
NOT VALID |
|||
); |
|||
|
|||
|
|||
INSERT INTO customers (name, email, age) VALUES ('Mike', 'mike@mike.com', 30); |
|||
INSERT INTO categories (name) VALUES ('Books'); |
|||
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
docker-compose down |
|||
docker volume prune -f |
|||
Loading…
Reference in new issue