Updates schema, adds PersonShippingAddresses table
This commit is contained in:
parent
35d5d22b49
commit
0535079c1c
|
@ -8,4 +8,4 @@ You will need to initialize a sqlite database store: `touch aural_isle.sqlite.db
|
||||||
|
|
||||||
You will need to copy the example env file to .env: `cp env.example .env`
|
You will need to copy the example env file to .env: `cp env.example .env`
|
||||||
|
|
||||||
Then you should be able to run the initial database migrations: `sqlx migrate run`
|
Then you should be able to run the initial database migrations: `sqlx migrate run`. (During initial dev, if you have already ran the initial migration, you will need to delete the sqlite database store and re-create it as above)
|
|
@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS Persons (
|
||||||
deleted_at INTEGER, /* timestamp */
|
deleted_at INTEGER, /* timestamp */
|
||||||
deleted_by TEXT(36), /* UUIDv4 */
|
deleted_by TEXT(36), /* UUIDv4 */
|
||||||
last_seen INTEGER, /* timestamp */
|
last_seen INTEGER, /* timestamp */
|
||||||
shipping_address TEXT, /* optional, should use \n between lines to keep localized format as needed */
|
/*shipping_address TEXT,*/ /* optional, should use \n between lines to keep localized format as needed - UPDATE: moving to lookup table */
|
||||||
CONSTRAINT Persons_PK PRIMARY KEY (id),
|
CONSTRAINT Persons_PK PRIMARY KEY (id),
|
||||||
CONSTRAINT Persons_FK FOREIGN KEY (modified_by) REFERENCES Persons(id),
|
CONSTRAINT Persons_FK FOREIGN KEY (modified_by) REFERENCES Persons(id),
|
||||||
CONSTRAINT Persons_FK_1 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
|
CONSTRAINT Persons_FK_1 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
|
||||||
|
@ -31,6 +31,24 @@ CREATE INDEX IF NOT EXISTS Persons_is_active_IDX ON Persons (is_active);
|
||||||
CREATE INDEX IF NOT EXISTS Persons_is_blocked_IDX ON Persons (is_blocked);
|
CREATE INDEX IF NOT EXISTS Persons_is_blocked_IDX ON Persons (is_blocked);
|
||||||
CREATE INDEX IF NOT EXISTS Persons_deleted_at_IDX ON Persons (deleted_at);
|
CREATE INDEX IF NOT EXISTS Persons_deleted_at_IDX ON Persons (deleted_at);
|
||||||
|
|
||||||
|
-- The PersonShippingAddresses table is a one-to-many lookup table relating a Person to zero or more shipping addresses
|
||||||
|
CREATE TABLE IF NOT EXISTS PersonShippingAddresses (
|
||||||
|
id TEXT(36), /* UUIDv4 */
|
||||||
|
person_id TEXT(36), /* UUIDv4 */
|
||||||
|
shipping_address TEXT, /* mandatory, should use \n between lines to keep localized format as needed */
|
||||||
|
is_primary INTEGER DEFAULT (0), /* bool, default false */
|
||||||
|
created_at INTEGER, /* timestamp */
|
||||||
|
modified_at INTEGER, /* timestamp */
|
||||||
|
modified_by TEXT(36), /* UUIDv4 */
|
||||||
|
deleted_at INTEGER, /* timestamp */
|
||||||
|
deleted_by TEXT(36), /* UUIDv4 */
|
||||||
|
CONSTRAINT PersonShippingAddresses_PK PRIMARY KEY (id),
|
||||||
|
CONSTRAINT PersonShippingAddresses_FK FOREIGN KEY (person_id) REFERENCES Persons(id),
|
||||||
|
CONSTRAINT PersonShippingAddresses_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
|
||||||
|
CONSTRAINT PersonShippingAddresses_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
|
||||||
|
);
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS PersonShippingAddresses_is_primary_IDX ON PersonShippingAddresses (is_primary);
|
||||||
|
|
||||||
-- The PersonEmails table is a one-to-many lookup table relating a Person to zero or more email addresses
|
-- The PersonEmails table is a one-to-many lookup table relating a Person to zero or more email addresses
|
||||||
CREATE TABLE IF NOT EXISTS PersonEmails (
|
CREATE TABLE IF NOT EXISTS PersonEmails (
|
||||||
person_id TEXT(36),
|
person_id TEXT(36),
|
||||||
|
|
Loading…
Reference in New Issue