Skip to content

Commit 44cef5e

Browse files
committed
Bring over from dependency project
1 parent 17b90b1 commit 44cef5e

21 files changed

Lines changed: 6326 additions & 0 deletions

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM flowdocker/postgresql:0.0.11
2+
3+
ADD . /opt/schema
4+
WORKDIR /opt/schema
5+
6+
RUN echo "set -x #echo on" >> /opt/run.sh
7+
RUN echo "service postgresql start" >> /opt/run.sh
8+
RUN echo "sh /opt/schema/install.sh" >> /opt/run.sh
9+
10+
RUN sh /opt/run.sh
11+
12+
USER "postgres"
13+
CMD ["/usr/lib/postgresql/9.4/bin/postgres", "-i", "-D", "/var/lib/postgresql/9.4/main"]

dev.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env ruby
2+
# == Wrapper script to update a local postgrseql database
3+
#
4+
# == Usage
5+
# ./dev.rb
6+
#
7+
8+
Dir.chdir(File.dirname($0)) {
9+
command = "sem-apply --url postgresql://api@localhost/dependencydb"
10+
puts command
11+
exec(command)
12+
}

install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
psql -U postgres -c 'create database dependencydb' postgres
4+
psql -U postgres --no-align --tuples-only -c "SELECT 1 FROM pg_roles WHERE rolname='api'" | grep -q 1 || psql -U postgres -c 'create role api login PASSWORD NULL' postgres
5+
psql -U postgres -c 'GRANT ALL ON DATABASE dependencydb TO api' postgres
6+
sem-apply --url postgresql://api@localhost/dependencydb

misc/clean-test-data.sql

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
update organizations
2+
set deleted_at=now()
3+
where deleted_at is null
4+
and key like 'z-test%';
5+
6+
update projects
7+
set deleted_at=now()
8+
where deleted_at is null
9+
and name like 'Z Test %';
10+
11+
update project_libraries
12+
set deleted_at=now()
13+
where deleted_at is null
14+
and project_id in (select id from projects where deleted_at is not null);
15+
16+
update project_binaries
17+
set deleted_at=now()
18+
where deleted_at is null
19+
and project_id in (select id from projects where deleted_at is not null);
20+
21+
update libraries
22+
set deleted_at=now()
23+
where deleted_at is null
24+
and group_id like 'z-test%';
25+
26+
update library_versions
27+
set deleted_at=now()
28+
where deleted_at is null
29+
and library_id not in (
30+
select libraries.id
31+
from libraries
32+
where libraries.deleted_at is null
33+
);
34+
35+
update binaries
36+
set deleted_at=now()
37+
where deleted_at is null
38+
and (lower(name) like 'z-test%' or lower(name) like 'z test%');
39+
40+
update binary_versions
41+
set deleted_at=now()
42+
where deleted_at is null
43+
and binary_id in (
44+
select binaries.id
45+
from binaries
46+
where binaries.deleted_at is not null
47+
);
48+
49+
update users
50+
set deleted_at=now()
51+
where deleted_at is null
52+
and email like 'z-test-%';
53+
54+
update github_users
55+
set deleted_at=now()
56+
where deleted_at is null
57+
and login like 'z-test-%';
58+
59+
update resolvers
60+
set deleted_at=now()
61+
where deleted_at is null
62+
and uri like '%z-test.flow.io%';
63+
64+
update tokens
65+
set deleted_at=now()
66+
where deleted_at is null
67+
and tag like 'z test%';
68+
69+
update items
70+
set deleted_at=now()
71+
where deleted_at is null
72+
and label like 'z-test%';
73+
74+
update subscriptions
75+
set deleted_at=now()
76+
where deleted_at is null
77+
and user_id in (select id from users where deleted_at is not null);
78+
79+
update last_emails
80+
set deleted_at=now()
81+
where deleted_at is null
82+
and user_id in (select id from users where deleted_at is not null);
83+

0 commit comments

Comments
 (0)