Skip to content
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

Closed
wants to merge 7 commits into from
Closed

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Sep 6, 2021

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 nft_storage schema.
  • Renamed account -> user.
  • Make issuer NOT the primary key on user, added id column for primary and referenced it from other tables.
  • Change user.issuer to user.magic_link_id and user.sub to user.github_id.
  • 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.
  • Added mime_type text field to upload.
  • Renamed content.size to content.dag_size for consistency with web3.storage.

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
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 6, 2021

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9c6949c
Status: ✅  Deploy successful!
Preview URL: https://d2be8717.nft-storage.pages.dev

View logs

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())
Copy link
Contributor

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

@Gozala
Copy link
Contributor

Gozala commented Sep 7, 2021

Generated diagram from here https://dbdiagram.io/d/6137ad47825b5b0146f766cf

@alanshaw
Copy link
Contributor Author

Closing this as the changes have been manually merged into #263

@alanshaw alanshaw closed this Sep 17, 2021
@alanshaw alanshaw deleted the feat/nftstorage-postgres-schema branch September 17, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants