add Init and Down script for tests

This commit is contained in:
2019-06-06 14:03:34 +02:00
parent 9b7d2ffa8c
commit f20d349c3d
4 changed files with 34 additions and 7 deletions

View File

@@ -0,0 +1,2 @@
drop schema public cascade;
create schema if not exists public;

View File

@@ -1,3 +1,8 @@
-- create database test;
-- create user test with encrypted password 'test';
-- grant all privileges on database test to test;
-- ALTER SCHEMA public owner to test;
create table if not exists test
(
id serial not null
@@ -14,7 +19,8 @@ create table if not exists test2
constraint test2_test_id_fk
references test
);
INSERT INTO public.test (id, name) VALUES (1, 'plop');
INSERT INTO public.test2 (id, title, test_id) VALUES (1, 'plop', 1);
INSERT INTO public.test2 (id, title, test_id) VALUES (2, 'plip', 1);
INSERT INTO public.test2 (id, title, test_id) VALUES (3, 'ttt', null);
INSERT INTO test (id, name) VALUES (1, 'plop') ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (1, 'plop', 1) ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (2, 'plip', 1) ON CONFLICT DO NOTHING;
INSERT INTO test2 (id, title, test_id) VALUES (3, 'ttt', null) ON CONFLICT DO NOTHING;