Fork of github.com/did-method-plc/did-method-plc

pr feedback

dholms 28a21c7b bdccd99e

Changed files
+17 -17
packages
+1 -1
packages/server/example.dev.env
···
-
DB_POSTGRES_URL="postgres://bsky:yksb@localhost/plc_dev"
+
DATABASE_URL="postgres://bsky:yksb@localhost/plc_dev"
DEBUG_MODE=1
LOG_ENABLED="true"
LOG_LEVEL=debug
+1 -1
packages/server/pg/README.md
···
This script allows you to run any command with a fresh, ephemeral/single-use postgres database available. When the script starts a Dockerized postgres container starts-up, and when the script completes that container is removed.
-
The environment variable `DB_POSTGRES_URL` will be set with a connection string that can be used to connect to the database. The [`PG*` environment variables](https://www.postgresql.org/docs/current/libpq-envars.html) that are recognized by libpq (i.e. used by the `psql` client) are also set.
+
The environment variable `DATABASE_URL` will be set with a connection string that can be used to connect to the database. The [`PG*` environment variables](https://www.postgresql.org/docs/current/libpq-envars.html) that are recognized by libpq (i.e. used by the `psql` client) are also set.
**Example**
+1 -1
packages/server/pg/with-test-db.sh
···
export PGUSER=pg
export PGPASSWORD=password
export PGDATABASE=postgres
-
export DB_POSTGRES_URL="postgresql://pg:password@localhost:5433/postgres"
+
export DATABASE_URL="postgresql://pg:password@localhost:5433/postgres"
"$@"
code=$?
+3 -3
packages/server/src/bin.ts
···
import PlcServer from '.'
const run = async () => {
-
const dbPostgresUrl = process.env.DB_POSTGRES_URL
+
const dbUrl = process.env.DATABASE_URL
let db: PlcDatabase
-
if (dbPostgresUrl) {
-
const pgDb = Database.postgres({ url: dbPostgresUrl })
+
if (dbUrl) {
+
const pgDb = Database.postgres({ url: dbUrl })
await pgDb.migrateToLatestOrThrow()
db = pgDb
} else {
+1 -1
packages/server/src/migrations/20230223T215019669Z-refactor.ts
···
.addColumn('cid', 'text', (col) => col.notNull())
.addColumn('nullified', 'boolean', (col) => col.notNull())
.addColumn('createdAt', 'timestamptz', (col) =>
-
col.defaultTo(sql`current_timestamp`),
+
col.notNull().defaultTo(sql`current_timestamp`),
)
.addPrimaryKeyConstraint('operations_primary_key', ['did', 'cid'])
.execute()
+6 -6
packages/server/tests/_util.ts
···
}
export const runTestServer = async (opts: {
-
dbPostgresSchema: string
+
dbSchema: string
}): Promise<TestServerInfo> => {
-
const { dbPostgresSchema } = opts
-
const dbPostgresUrl = process.env.DB_POSTGRES_URL
-
if (!dbPostgresUrl) {
+
const { dbSchema } = opts
+
const dbUrl = process.env.DATABASE_URL
+
if (!dbUrl) {
throw new Error('No postgres url provided')
}
const db = Database.postgres({
-
url: dbPostgresUrl,
-
schema: dbPostgresSchema,
+
url: dbUrl,
+
schema: dbSchema,
})
await db.migrateToLatestOrThrow()
+3 -3
packages/server/tests/migrations/refactor.test.ts
···
let rawDb: Kysely<any>
beforeAll(async () => {
-
const dbPostgresUrl = process.env.DB_POSTGRES_URL
-
if (!dbPostgresUrl) {
+
const dbUrl = process.env.DATABASE_URL
+
if (!dbUrl) {
throw new Error('No postgres url provided')
}
db = Database.postgres({
-
url: dbPostgresUrl,
+
url: dbUrl,
schema: 'migration_refactor',
})
+1 -1
packages/server/tests/server.test.ts
···
beforeAll(async () => {
const server = await runTestServer({
-
dbPostgresSchema: 'server',
+
dbSchema: 'server',
})
db = server.db