-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
666f607
commit ce0b360
Showing
7 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM postgres:15.2-alpine as builder | ||
|
||
ENV VERSION v4.15.2 | ||
WORKDIR /db | ||
|
||
RUN apk --no-cache add curl && \ | ||
curl -L https://github.com/golang-migrate/migrate/releases/download/$VERSION/migrate.linux-amd64.tar.gz \ | ||
| tar xvz | ||
|
||
COPY ./db/migrations ./migrations | ||
COPY ./db/seeds ./seeds | ||
COPY ./db/run-dev-migrations ./run-dev-migrations | ||
|
||
CMD ["./run-dev-migrations"] | ||
|
||
FROM alpine:3.17 | ||
|
||
WORKDIR /db | ||
|
||
COPY --from=builder /db/migrate ./migrate | ||
COPY ./db/migrations ./migrations | ||
|
||
ENTRYPOINT ./migrate -path migrations -database "$DB_URL" up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
begin; | ||
|
||
create table payrolls | ||
( | ||
id uuid not null, | ||
tenant_id uuid not null, | ||
payday date not null | ||
); | ||
alter table payrolls | ||
add constraint payrolls_pkey primary key (id); | ||
|
||
create table payslips | ||
( | ||
id uuid not null, | ||
tenant_id uuid not null, | ||
payroll_id uuid not null, | ||
|
||
gross_pay int not null default 0, | ||
tax int not null default 0, | ||
net_pay int not null default 0 | ||
); | ||
alter table payslips | ||
add constraint payslis_pkey primary key (id); | ||
alter table payslips | ||
add constraint payslips_payrolls_fkey | ||
foreign key (payroll_id) references payrolls(id); | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
./migrate -path migrations -database "$DB_URL" up | ||
|
||
# Seeds | ||
psql "$DB_URL" -f seeds/payrolls.sql |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters