feat(supabase): sheet asset Storage bucket + read policy through the sheet, shim storage tables, seeds in the PGlite harness, upload script
This commit is contained in:
1 parent
12f0b21fdf
commit
f4682cdba5
10 files changed
+294
-7
No files matched your search
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* PGlite harness: a real PostgreSQL (WASM) that applies the Supabase shim,
|
||||
* then every migration under supabase/migrations, in filename order.
|
||||
* then every migration under supabase/migrations, in filename order, then
|
||||
* the versioned seeds under supabase/seed (same files `supabase db reset`
|
||||
* applies through config.toml sql_paths).
|
||||
* Lets the pgTAP suite and the schema checks run without Docker. The same
|
||||
* SQL runs unchanged under `supabase test db` on the real stack.
|
||||
*/
|
||||
@@ -15,6 +17,8 @@ export const repoRoot = resolve(here, '../../../..')
|
||||
export const supabaseDir = join(repoRoot, 'supabase')
|
||||
export const migrationsDir = join(supabaseDir, 'migrations')
|
||||
export const pgTapTestsDir = join(supabaseDir, 'tests')
|
||||
/** Versioned seeds (reference data such as the official sheets); seed.sql itself needs the real auth schema and stays out. */
|
||||
export const seedDir = join(supabaseDir, 'seed')
|
||||
|
||||
async function listSqlFiles(dir: string): Promise<string[]> {
|
||||
const entries = await readdir(dir)
|
||||
@@ -29,6 +33,12 @@ export async function listPgTapTests(): Promise<string[]> {
|
||||
return listSqlFiles(pgTapTestsDir)
|
||||
}
|
||||
|
||||
/** Every .sql under supabase/seed, recursively, in path order. */
|
||||
export async function listSeeds(): Promise<string[]> {
|
||||
const entries = await readdir(seedDir, { recursive: true }).catch(() => [])
|
||||
return entries.filter((f) => f.endsWith('.sql')).sort()
|
||||
}
|
||||
|
||||
/** Boots PGlite, installs the shim and applies all migrations. */
|
||||
export async function createMigratedDatabase(): Promise<PGlite> {
|
||||
const db = await PGlite.create({ extensions: { pgtap } })
|
||||
@@ -39,6 +49,9 @@ export async function createMigratedDatabase(): Promise<PGlite> {
|
||||
for (const file of await listMigrations()) {
|
||||
await db.exec(await readFile(join(migrationsDir, file), 'utf8'))
|
||||
}
|
||||
for (const file of await listSeeds()) {
|
||||
await db.exec(await readFile(join(seedDir, file), 'utf8'))
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user