web3.storage currently uses Postgres and its setup can be seen next.
You will need to install docker (check official docker documentation) and postgres locally.
brew install postgres
Please follow the instructions in the main monorepo Readme.
If you want to run your own local DB in isolation using this package DB client, you can easily do it as follows:
Start a docker compose with a Postgres Database and Postgrest.
npm start
npm run load-schema
You can now interact with your local database. Its URL and Token are defined in the previous section.
Once you are done, the local setup can easily be stopped:
npm stop
If you'd like to also clear the database and all docker artifacts you can run
npm run stop:clean
-
Add the schema changes to
db/postgres
sql files as needed. -
Apply the changes to the Postgres DB using:
node scripts/cli.js --reset db-sql
-
Run the following which uses
openapi-typescript
to updatepg-rest-api-types.ts
, the TypeScript interface version of the OpenAPI schema for the updated DB:node scripts/cli.js pg-rest-api-types
-
Add the schema changes to
db-client-types.ts
as well. -
If the schema changes include creating a new table, type or view update
reset.sql
as well. -
Add the required migration script(s) to postgres/migrations folder. Please follow the naming convention and add an incremental number prefix to the name of the migration file.
-
Once the PR is merged to main please add a comment to the release-please PR pointing to the migrations script.
ieRequired migration 000-fix-peer_location.peer_id.sql
The scripts/cli.js
to run some common operations on the database.
Please run
./scripts/cli.js --help
to find out more.
Powered by dbdiagram.io.