-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: postgres schema #395
Conversation
I've taken the schema from #263 with the following changes: * Primary keys are called `id` except where we're using domain data as the primary key (currently only `cid` in content) * Use shortened primary key definition to use `BIGSERIAL` for enhanced readability * Added `nftstorage` schema * Renamed `account` -> `user` * Make `issuer` NOT the primary key on `user`, added `id` column for primary and referenced it from other tables * Prefixed foreign keys with (complete) referenced table name where appropriate * Renamed `cid` in the `upload` table to `source_cid` so more obvious it is the given/original/provided/source CID * Added the `deleted_at` column to `upload` (and had to remove the `UNIQUE` constraint because of it) * Consistent enums capitalization to match web3.storage and niftysave * Added `upload_type` enum * Renamed `content.size` to `content.dag_size` for consistency with web3.storage
Deploying with
|
Latest commit: |
9c6949c
|
Status: | ✅ Deploy successful! |
Preview URL: | https://d2be8717.nft-storage.pages.dev |
packages/db/tables.sql
Outdated
meta jsonb, | ||
inserted_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL, | ||
updated_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL, | ||
deleted_at timestamp with time zone DEFAULT timezone('utc'::text, now()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding the deleted_at forces changes in the function.sql, the upload_fn
needs to account for this in the ON CONFLICT
clause.
i have this task in my todo already
Generated diagram from here https://dbdiagram.io/d/6137ad47825b5b0146f766cf |
Closing this as the changes have been manually merged into #263 |
I've taken the schema from #263 with the following changes:
id
except where we're using domain data as the primary key (currently onlycid
in content).BIGSERIAL
for enhanced readability.Addednft_storage
schema.account
->user
.issuer
NOT the primary key onuser
, addedid
column for primary and referenced it from other tables.user.issuer
touser.magic_link_id
anduser.sub
touser.github_id
.cid
in theupload
table tosource_cid
so more obvious it is the given/original/provided/source CID.deleted_at
column toupload
(and had to remove theUNIQUE
constraint because of it).upload_type
enum.mime_type
text field toupload
.content.size
tocontent.dag_size
for consistency with web3.storage.