-
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
dc9087b
commit 9349e22
Showing
2 changed files
with
18 additions
and
0 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,5 @@ | ||
ALTER TABLE IF EXISTS "accounts" DROP CONSTRAINT IF EXISTS "owner_currency_key"; | ||
|
||
ALTER TABLE IF EXISTS "accounts" DROP CONSTRAINT IF EXISTS "accounts_owner_fkey"; | ||
|
||
DROP TABLE IF EXISTS "users"; |
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,13 @@ | ||
CREATE TABLE "users" ( | ||
"username" varchar PRIMARY KEY, | ||
"hashed_password" varchar NOT NULL, | ||
"full_name" varchar NOT NULL, | ||
"email" varchar UNIQUE NOT NULL, | ||
"password_changed_at" timestamptz NOT NULL DEFAULT ('0001-01-01 00:00:00+00'), | ||
"created_at" timestamptz NOT NULL DEFAULT (now()) | ||
); | ||
|
||
ALTER TABLE "accounts" ADD FOREIGN KEY ("owner") REFERENCES "users" ("username"); | ||
|
||
-- CREATE UNIQUE INDEX ON "accounts" ("owner", "currency"); | ||
ALTER TABLE "accounts" ADD CONSTRAINT "owner_currency_key" UNIQUE ("owner", "currency"); |