rename src to source

This commit is contained in:
2026-07-27 10:19:13 +00:00
parent 35d38d4465
commit 75f84f6302
26 changed files with 15 additions and 15 deletions
@@ -0,0 +1,37 @@
import type { Kysely } from 'kysely';
import { sql } from 'kysely';
import type { DatabaseTables } from '../tables.ts';
/**
* Helper for converting the current time to a millisecond timestamp.
*
* @returns SQLite expression producing the current time in milliseconds.
*/
const millisecondTime = sql`(CAST(unixepoch('subsec') * 1000 AS INTEGER))`;
/**
* Creates the resource_data table.
*
* @param db - Kysely database to apply the migration against.
*/
export const up = async (db: Kysely<DatabaseTables>): Promise<void> => {
// Composite primary key enforces one blob slot per (resource, public key).
await db.schema
.createTable('resource_data')
.ifNotExists()
.addColumn('resource_id', 'text', (col) => col.notNull())
.addColumn('public_key', 'text', (col) => col.notNull())
.addColumn('blob', 'blob', (col) => col.notNull())
.addColumn('timestamp', 'integer', (col) => col.notNull().defaultTo(millisecondTime))
.addPrimaryKeyConstraint('pk_resource_data', ['resource_id', 'public_key'])
.execute();
};
/**
* Drops the resource_data table.
*
* @param db - Kysely database to apply the rollback against.
*/
export const down = async (db: Kysely<DatabaseTables>): Promise<void> => {
await db.schema.dropTable('resource_data').ifExists().execute();
};