adds Cargo.lock, updates gitignore, updates SCHEMA with initial table definitions for a couple of tables based on MODELS

This commit is contained in:
Sundog 2023-10-18 15:55:07 -04:00
parent 483d34d106
commit 1359dca5df
3 changed files with 1196 additions and 2 deletions

4
.gitignore vendored
View File

@ -6,7 +6,7 @@ target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
@ -14,3 +14,5 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# No need to store databases in the git repo
**/*.sqlite

1140
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,53 @@
# TODO
# SCHEMA
This file represents the initial schema for the various data structures to be stored in the database.
These schema definitions target SQLite v3.
# Persons Table
The Persons table will contain data about Person entities (see MODELS.md)
``` sql
CREATE TABLE Persons (
id TEXT(36), /* UUIDv4 */
remote_id TEXT, /* field to store an arbitrary remote identifier for this Person if they are not local */
name TEXT, /* "real" name */
handle TEXT, /* also commonly refered to as 'display_name' or 'screen_name', optional (if missing, name will be used as handle) */
is_active INTEGER DEFAULT (1), /* bool, default true */
is_blocked 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 */
last_seen INTEGER, /* timestamp */
shipping_address TEXT, /* optional, should use \n between lines to keep localized format as needed */
CONSTRAINT Persons_PK PRIMARY KEY (id),
CONSTRAINT Persons_FK FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT Persons_FK_1 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE UNIQUE INDEX Persons_remote_id_IDX ON Persons (remote_id);
CREATE INDEX Persons_name_IDX ON Persons (name);
CREATE INDEX Persons_handle_IDX ON Persons (handle);
CREATE INDEX Persons_is_active_IDX ON Persons (is_active);
CREATE INDEX Persons_is_blocked_IDX ON Persons (is_blocked);
CREATE INDEX Persons_deleted_at_IDX ON Persons (deleted_at);
```
# PersonEmails Table
The PersonEmails table is a one-to-many lookup table relating a Person to zero or more email addresses
``` sql
CREATE TABLE PersonEmails (
person_id TEXT(36),
email TEXT,
is_verified INTEGER DEFAULT (0),
is_primary INTEGER DEFAULT (0),
CONSTRAINT PersonEmails_PK PRIMARY KEY (email),
CONSTRAINT PersonEmails_FK FOREIGN KEY (person_id) REFERENCES Persons(id) ON DELETE CASCADE
);
CREATE INDEX PersonEmails_person_id_IDX ON PersonEmails (person_id);
CREATE INDEX PersonEmails_is_verified_IDX ON PersonEmails (is_verified);
CREATE INDEX PersonEmails_is_primary_IDX ON PersonEmails (is_primary);
```