-
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
a2da98f
commit c5dfb6c
Showing
5 changed files
with
60 additions
and
42 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,10 @@ | ||
postgres: | ||
docker run --name postgres -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=<password> -d postgres:latest | ||
|
||
createdb: | ||
docker exec -it postgres createdb --username=root --owner=root simple_bank | ||
|
||
dropdb: | ||
docker exec -it postgres drobdb simple_bank | ||
|
||
.PHONY: postgres createdb dropdb |
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# go-playground | ||
Go code for public personal projects | ||
|
||
## project ideas | ||
1. card counting app | ||
2. some terminal based game? |
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,3 @@ | ||
DROP TABLE IF EXISTS entries; | ||
DROP TABLE IF EXISTS transfers; | ||
DROP TABLE IF EXISTS accounts; |
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,43 @@ | ||
CREATE TABLE "accounts" ( | ||
"id" bigserial PRIMARY KEY, | ||
"owner" varchar NOT NULL, | ||
"balance" bigint NOT NULL, | ||
"currency" varchar NOT NULL, | ||
"created_at" timestamptz NOT NULL DEFAULT (now()) | ||
); | ||
|
||
CREATE TABLE "entries" ( | ||
"id" bigserial PRIMARY KEY, | ||
"account_id" bigint, | ||
"amount" bigint NOT NULL, | ||
"created_at" timestamptz NOT NULL DEFAULT (now()) | ||
); | ||
|
||
CREATE TABLE "transfers" ( | ||
"id" bigserial PRIMARY KEY, | ||
"from_account_id" bigint, | ||
"to_account_id" bigint, | ||
"amount" bigint NOT NULL, | ||
"created_at" timestamptz NOT NULL DEFAULT (now()) | ||
); | ||
|
||
CREATE INDEX ON "accounts" ("owner"); | ||
|
||
CREATE INDEX ON "entries" ("account_id"); | ||
|
||
CREATE INDEX ON "transfers" ("from_account_id"); | ||
|
||
CREATE INDEX ON "transfers" ("to_account_id"); | ||
|
||
CREATE INDEX ON "transfers" ("from_account_id", "to_account_id"); | ||
|
||
COMMENT ON COLUMN "entries"."amount" IS 'can be negative or positive'; | ||
|
||
COMMENT ON COLUMN "transfers"."amount" IS 'must be positive'; | ||
|
||
ALTER TABLE "entries" ADD FOREIGN KEY ("account_id") REFERENCES "accounts" ("id"); | ||
|
||
ALTER TABLE "transfers" ADD FOREIGN KEY ("from_account_id") REFERENCES "accounts" ("id"); | ||
|
||
ALTER TABLE "transfers" ADD FOREIGN KEY ("to_account_id") REFERENCES "accounts" ("id"); | ||
|
This file was deleted.
Oops, something went wrong.