supaschema 0.1.0-rc.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/diagnostics.md +0 -3
- package/docs/support-matrix.md +0 -10
- package/package.json +1 -1
- package/dist/benchmark-db.d.ts +0 -5
- package/dist/benchmark-db.d.ts.map +0 -1
- package/dist/benchmark-db.js +0 -71
package/docs/diagnostics.md
CHANGED
|
@@ -72,6 +72,3 @@ Diagnostics have `code`, `severity`, `message`, and optional `ref`, `file`, `sta
|
|
|
72
72
|
| `SUPA_VERIFY_FINGERPRINT_MISMATCH` hints | — | The mismatch hint names the differing objects: missing from the migration result, not present in the target, and definition differs. |
|
|
73
73
|
| `SUPA_VERIFY_FAILED` | error | Temporary database verification failed. |
|
|
74
74
|
| `SUPA_VERIFY_FINGERPRINT_MISMATCH` | error | Applying the migration twice did not produce the target catalog fingerprint. |
|
|
75
|
-
| `SUPA_VERIFY_ROLE_CAPABILITY` | error | The verification role cannot `CREATE DATABASE`; use a role with `CREATEDB` (on local Supabase stacks prefer `supabase_admin`). |
|
|
76
|
-
| `SUPA_VERIFY_STUB_REFERENCE` | warning | A `verify` failure under `--ensure-environment` references a Supabase-managed schema that the environment stub only provisions minimally; the failure may be a stub limitation rather than a real migration defect. Re-run against a real Supabase database to confirm. |
|
|
77
|
-
| `SUPA_VERIFY_RECONVERGENCE` | error | The migrated catalog cross-lane diffed against the target model is not empty; the model declares state the catalog cannot reproduce (false drift), or lane parity is broken. |
|
package/docs/support-matrix.md
CHANGED
|
@@ -29,16 +29,6 @@
|
|
|
29
29
|
|
|
30
30
|
With `adapter: "supabase-auto"`, objects in these platform-owned schemas are blocked: `auth`, `storage`, `realtime`, `vault`, `extensions`, `cron`, `net`, `supabase_functions`, `graphql`, and `graphql_public`.
|
|
31
31
|
|
|
32
|
-
## Verify Environment Stub
|
|
33
|
-
|
|
34
|
-
`verify --ensure-environment` (the default under `adapter: "supabase-auto"`) provisions a minimal stand-in for the Supabase-provisioned surface so a declarative tree that _references_ managed schemas can apply against bare PostgreSQL:
|
|
35
|
-
|
|
36
|
-
- `auth.users` with the stable GoTrue column set (`id`, `aud`, `role`, `email`, `phone`, `raw_app_meta_data`, `raw_user_meta_data`, `last_sign_in_at`, `is_anonymous`, …).
|
|
37
|
-
- The `auth.uid()`, `auth.role()`, `auth.jwt()`, and `auth.email()` helper functions.
|
|
38
|
-
- The `cron.job` and `cron.job_run_details` tables.
|
|
39
|
-
|
|
40
|
-
The stub is symmetric across both temporary databases and subtracted from the reconvergence check, so it never affects catalog parity. It is an **approximation**: other managed objects (`storage.*`, `realtime.*`, `vault.*`, `auth.identities`, `auth.sessions`, …) are not stubbed. A migration that references an un-stubbed managed object fails verify with `SUPA_VERIFY_FAILED` plus a `SUPA_VERIFY_STUB_REFERENCE` warning naming the schema — that failure may be a stub limitation rather than a real defect; re-run verify against a real Supabase database (without `--ensure-environment`) to confirm.
|
|
41
|
-
|
|
42
32
|
## Examples
|
|
43
33
|
|
|
44
34
|
- `examples/supabase/schemas` demonstrates Supabase-style declarative schema input with RLS and policies; `examples/supabase/schemas-next` is the evolved tree, so a full diff runs out of the box:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supaschema",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "From declarative schema to fully synced database in milliseconds with one command. No ORM, no Docker, and no shadow database needed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
package/dist/benchmark-db.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function withTemporaryDatabases<T>(databaseUrl: string, count: number, callback: (databaseUrls: string[]) => Promise<T>): Promise<T>;
|
|
2
|
-
export declare function applySql(databaseUrl: string, sql: string): Promise<void>;
|
|
3
|
-
export declare function applyMigrationSql(databaseUrl: string, sql: string): Promise<void>;
|
|
4
|
-
export declare function databasePair(databaseUrls: string[]): [string, string];
|
|
5
|
-
//# sourceMappingURL=benchmark-db.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"benchmark-db.d.ts","sourceRoot":"","sources":["../src/benchmark-db.ts"],"names":[],"mappings":"AAIA,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,CAAC,CA2BZ;AAED,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU9E;AAID,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAYvF;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMrE"}
|
package/dist/benchmark-db.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Client } from "pg";
|
|
2
|
-
import { quoteIdent } from "./sql/identifiers.js";
|
|
3
|
-
import { splitSqlStatements } from "./sql/split.js";
|
|
4
|
-
export async function withTemporaryDatabases(databaseUrl, count, callback) {
|
|
5
|
-
const admin = new Client({ connectionString: databaseUrl });
|
|
6
|
-
const created = [];
|
|
7
|
-
try {
|
|
8
|
-
await admin.connect();
|
|
9
|
-
for (let index = 0; index < count; index += 1) {
|
|
10
|
-
const databaseName = tempDatabaseName(index);
|
|
11
|
-
await admin.query(`CREATE DATABASE ${quoteIdent(databaseName)}`);
|
|
12
|
-
created.push(databaseName);
|
|
13
|
-
}
|
|
14
|
-
return await callback(created.map((databaseName) => databaseUrlWithDatabase(databaseUrl, databaseName)));
|
|
15
|
-
}
|
|
16
|
-
finally {
|
|
17
|
-
for (const databaseName of created.reverse()) {
|
|
18
|
-
await admin
|
|
19
|
-
.query(`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $1 AND pid <> pg_backend_pid()`, [databaseName])
|
|
20
|
-
.catch(() => undefined);
|
|
21
|
-
await admin
|
|
22
|
-
.query(`DROP DATABASE IF EXISTS ${quoteIdent(databaseName)} WITH (FORCE)`)
|
|
23
|
-
.catch(() => undefined);
|
|
24
|
-
}
|
|
25
|
-
await admin.end().catch(() => undefined);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export async function applySql(databaseUrl, sql) {
|
|
29
|
-
const client = new Client({ connectionString: databaseUrl });
|
|
30
|
-
try {
|
|
31
|
-
await client.connect();
|
|
32
|
-
for (const statement of splitSqlStatements(sql)) {
|
|
33
|
-
await client.query(statement);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
await client.end().catch(() => undefined);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// One transaction per migration mirrors runners like `supabase db push`; an
|
|
41
|
-
// error leaves the transaction uncommitted and ending the connection aborts it.
|
|
42
|
-
export async function applyMigrationSql(databaseUrl, sql) {
|
|
43
|
-
const client = new Client({ connectionString: databaseUrl });
|
|
44
|
-
try {
|
|
45
|
-
await client.connect();
|
|
46
|
-
await client.query("BEGIN");
|
|
47
|
-
for (const statement of splitSqlStatements(sql)) {
|
|
48
|
-
await client.query(statement);
|
|
49
|
-
}
|
|
50
|
-
await client.query("COMMIT");
|
|
51
|
-
}
|
|
52
|
-
finally {
|
|
53
|
-
await client.end().catch(() => undefined);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export function databasePair(databaseUrls) {
|
|
57
|
-
const [fromUrl, toUrl] = databaseUrls;
|
|
58
|
-
if (!fromUrl || !toUrl) {
|
|
59
|
-
throw new Error("expected two temporary benchmark databases");
|
|
60
|
-
}
|
|
61
|
-
return [fromUrl, toUrl];
|
|
62
|
-
}
|
|
63
|
-
function databaseUrlWithDatabase(databaseUrl, databaseName) {
|
|
64
|
-
const url = new URL(databaseUrl);
|
|
65
|
-
url.pathname = `/${databaseName}`;
|
|
66
|
-
return url.toString();
|
|
67
|
-
}
|
|
68
|
-
function tempDatabaseName(index) {
|
|
69
|
-
const suffix = `${process.pid}_${Date.now()}_${index}_${Math.random().toString(16).slice(2)}`;
|
|
70
|
-
return `pg_diverge_benchmark_${suffix}`.replace(/[^A-Za-z0-9_]/g, "_").slice(0, 60);
|
|
71
|
-
}
|