fixed syntax for foreign keys
This commit is contained in:
parent
c06e926627
commit
5f1591c856
|
|
@ -2,7 +2,7 @@ CREATE table IF NOT EXISTS accounts(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
accountnum VARCHAR UNIQUE NOT NULL,
|
accountnum VARCHAR UNIQUE NOT NULL,
|
||||||
accountname VARCHAR UNIQUE NOT NULL,
|
accountname VARCHAR UNIQUE NOT NULL,
|
||||||
orgid int -- this needs to be a foregn key on organizations
|
REFERENCES organizations(id) ON DELETE SET NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS organizations(
|
CREATE TABLE IF NOT EXISTS organizations(
|
||||||
|
|
@ -15,28 +15,29 @@ id SERIAL PRIMARY KEY,
|
||||||
datetime DATE NOT NULL,
|
datetime DATE NOT NULL,
|
||||||
description VARCHAR NOT NULL,
|
description VARCHAR NOT NULL,
|
||||||
amount REAL NOT NULL,
|
amount REAL NOT NULL,
|
||||||
accountid INT NOT NULL --foreign key from accounts
|
accountid INT NOT NULL REFERENCES accounts(id) ON DELETE SET NULL,
|
||||||
orgid INT NOT NULL --foreign key from organizations
|
orgid INT NOT NULL REFERENCES organizations(id) ON DELETE SET NULL
|
||||||
)
|
)
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS snapshots(
|
CREATE TABLE IF NOT EXISTS snapshots(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
datetime DATE NOT NULL,
|
datetime DATE NOT NULL,
|
||||||
accountid INT NOT NULL, --foreign key from accounts
|
accountid INT NOT NULL REFERENCES accounts(id) ON DELETE SET NULL,
|
||||||
balance REAL NOT NULL,
|
balance REAL NOT NULL,
|
||||||
orgid INT NOT NULL --foreign key from organizations
|
orgid INT NOT NULL REFERENCES organizations(id) ON DELETE SET NULL
|
||||||
)
|
)
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS syncs(
|
CREATE TABLE IF NOT EXISTS syncs(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
datetime DATE NOT NULL,
|
datetime DATE NOT NULL,
|
||||||
accountid INT NOT NULL, --foreign key from accounts
|
accountid INT NOT NULL REFERENCES accounts(id) ON DELETE SET NULL,
|
||||||
orgid INT NOT NULL --foreign key from organizations
|
orgid INT NOT NULL REFERENCES organizations(id) ON DELETE SET NULL
|
||||||
)
|
)
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS vendors(
|
CREATE TABLE IF NOT EXISTS vendors(
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
vendorname VARCHAR NOT NULL,
|
vendorname VARCHAR NOT NULL,
|
||||||
|
orgid INT NOT NULL REFERENCES organizations(id) ON DELETE SET NULL
|
||||||
)
|
)
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS rawtransactions(
|
CREATE TABLE IF NOT EXISTS rawtransactions(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue