mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
SQL: currency and account names are unique
This commit is contained in:
parent
8c4f7f5a5c
commit
17ea4c72c6
1 changed files with 3 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
|||
CREATE SEQUENCE currencies_id_seq START WITH 1 INCREMENT BY 1;
|
||||
CREATE TABLE currencies (
|
||||
id INTEGER PRIMARY KEY NOT NULL DEFAULT NEXTVAL('currencies_id_seq'::regclass),
|
||||
name VARCHAR(128) NOT NULL
|
||||
name VARCHAR(128) NOT NULL,
|
||||
UNIQUE(name)
|
||||
);
|
||||
INSERT INTO currencies (name) VALUES ('Kč');
|
||||
|
||||
|
@ -30,6 +31,7 @@ CREATE TABLE accounts (
|
|||
id INTEGER PRIMARY KEY NOT NULL DEFAULT NEXTVAL('accounts_id_seq'::regclass),
|
||||
|
||||
name VARCHAR(128) NOT NULL,
|
||||
UNIQUE (name),
|
||||
|
||||
currency INTEGER NOT NULL,
|
||||
FOREIGN KEY (currency) REFERENCES currencies (id),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue