mirror of
https://github.com/wahyd4/heygo.git
synced 2026-08-09 05:15:52 +10:00
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const root = process.cwd();
|
|
const migrationSql = () => readFileSync(join(root, 'migrations', '0001_init.sql'), 'utf8');
|
|
|
|
describe('initial D1 schema migration', () => {
|
|
it('creates the required application tables', () => {
|
|
const sql = migrationSql();
|
|
|
|
for (const table of [
|
|
'users',
|
|
'oauth_accounts',
|
|
'sessions',
|
|
'links',
|
|
'tags',
|
|
'link_tags',
|
|
'promotion_submissions',
|
|
'click_daily',
|
|
]) {
|
|
expect(sql).toContain(`CREATE TABLE ${table} (`);
|
|
}
|
|
});
|
|
|
|
it('defines scoped alias and lookup indexes for links and promotions', () => {
|
|
const sql = migrationSql();
|
|
|
|
expect(sql).toContain('CREATE UNIQUE INDEX links_public_alias_unique');
|
|
expect(sql).toContain('CREATE UNIQUE INDEX links_private_owner_alias_unique');
|
|
expect(sql).toContain('CREATE INDEX links_owner_idx ON links(owner_user_id, updated_at DESC);');
|
|
expect(sql).toContain('CREATE INDEX links_scope_updated_idx ON links(scope, updated_at DESC);');
|
|
expect(sql).toContain('CREATE INDEX promotion_status_idx ON promotion_submissions(status, created_at DESC);');
|
|
});
|
|
});
|