first commit
This commit is contained in:
commit
0e1ce93def
12 files changed
+1693
No files matched your search
+68
@@ -0,0 +1,68 @@
|
||||
// Populates the DB with placeholder rows so the API has something to return
|
||||
// immediately. Re-runnable: clears each table before inserting.
|
||||
import Database from 'better-sqlite3';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import path from 'node:path';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const db = new Database(path.join(__dirname, 'tachyon.db'));
|
||||
|
||||
db.exec(`
|
||||
DELETE FROM sessions;
|
||||
DELETE FROM users;
|
||||
DELETE FROM news_posts;
|
||||
DELETE FROM media_items;
|
||||
DELETE FROM activity_log;
|
||||
DELETE FROM site_stats;
|
||||
`);
|
||||
|
||||
const insertNews = db.prepare(
|
||||
'INSERT INTO news_posts (title, content, created_at) VALUES (?, ?, ?)'
|
||||
);
|
||||
insertNews.run('Placeholder announcement title', 'Short placeholder line describing an update or change.', '2026-07-06T12:00:00.000Z');
|
||||
insertNews.run('Placeholder announcement title', 'Short placeholder line describing an update or change.', '2026-07-02T12:00:00.000Z');
|
||||
insertNews.run('Placeholder announcement title', 'Short placeholder line describing an update or change.', '2026-06-27T12:00:00.000Z');
|
||||
|
||||
const insertMedia = db.prepare(
|
||||
'INSERT INTO media_items (title, media_type, url) VALUES (?, ?, ?)'
|
||||
);
|
||||
insertMedia.run('placeholder clip one', 'image', 'https://example.com/media/1.png');
|
||||
insertMedia.run('placeholder clip two', 'image', 'https://example.com/media/2.png');
|
||||
insertMedia.run('placeholder clip three', 'video', 'https://example.com/media/3.mp4');
|
||||
insertMedia.run('placeholder clip four', 'image', 'https://example.com/media/4.png');
|
||||
|
||||
const insertUser = db.prepare(
|
||||
'INSERT INTO users (username, joined_at, last_seen_at) VALUES (?, ?, ?)'
|
||||
);
|
||||
const u1 = insertUser.run('placeholder_user_01', '2025-01-10T00:00:00.000Z', '2026-07-08T18:00:00.000Z');
|
||||
const u2 = insertUser.run('placeholder_user_02', '2025-03-22T00:00:00.000Z', '2026-07-08T17:45:00.000Z');
|
||||
const u3 = insertUser.run('placeholder_user_03', '2025-05-01T00:00:00.000Z', '2026-07-08T17:30:00.000Z');
|
||||
|
||||
const insertSession = db.prepare(
|
||||
'INSERT INTO sessions (user_id, started_at) VALUES (?, ?)'
|
||||
);
|
||||
// open sessions (no ended_at) = "currently online" for the Current Users column
|
||||
insertSession.run(u1.lastInsertRowid, '2026-07-08T18:00:00.000Z');
|
||||
insertSession.run(u2.lastInsertRowid, '2026-07-08T17:45:00.000Z');
|
||||
insertSession.run(u3.lastInsertRowid, '2026-07-08T17:30:00.000Z');
|
||||
|
||||
const insertActivity = db.prepare(
|
||||
'INSERT INTO activity_log (description, created_at) VALUES (?, ?)'
|
||||
);
|
||||
insertActivity.run('placeholder event one', '2026-07-08T17:00:00.000Z');
|
||||
insertActivity.run('placeholder event two', '2026-07-08T15:00:00.000Z');
|
||||
insertActivity.run('placeholder event three', '2026-07-08T13:00:00.000Z');
|
||||
insertActivity.run('placeholder event four', '2026-07-08T09:00:00.000Z');
|
||||
|
||||
const upsertStat = db.prepare(
|
||||
'INSERT INTO site_stats (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = strftime(\'%Y-%m-%dT%H:%M:%fZ\', \'now\')'
|
||||
);
|
||||
upsertStat.run('build_pipeline', 'Completed');
|
||||
upsertStat.run('build_number', '00000000');
|
||||
upsertStat.run('version', '0.0.0');
|
||||
upsertStat.run('reports_named', '00');
|
||||
upsertStat.run('reports_associated', '00');
|
||||
upsertStat.run('reports_logged', '00');
|
||||
|
||||
console.log('Seeded placeholder data.');
|
||||
db.close();
|
||||
Reference in new issue
Block a user