Skip to content

Commit bd13aeb

Browse files
committed
feat(briefings): add temporary script for testing briefing creation and management
1 parent 6ed7d18 commit bd13aeb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

scripts-tmp-test-briefing.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createClient } from '@libsql/client'
2+
3+
const client = createClient({
4+
url: process.env.TURSO_DATABASE_URL,
5+
authToken: process.env.TURSO_AUTH_TOKEN,
6+
})
7+
8+
const now = Date.now()
9+
const b = await client.execute({
10+
sql: `INSERT INTO briefings (title, status, objective, created_at, updated_at) VALUES (?, 'borrador', 'test', ?, ?) RETURNING id`,
11+
args: ['TEST briefing verificación', now, now],
12+
})
13+
const briefingId = b.rows[0].id
14+
console.log('briefing creado id=', briefingId)
15+
16+
await client.execute({
17+
sql: `INSERT INTO briefing_items (briefing_id, kind, content, done, sort_order, created_at) VALUES (?, 'requerimiento', 'ítem de prueba', 0, 0, ?)`,
18+
args: [briefingId, now],
19+
})
20+
const items = await client.execute({ sql: 'SELECT * FROM briefing_items WHERE briefing_id = ?', args: [briefingId] })
21+
console.log('items:', items.rows)
22+
23+
await client.execute({ sql: 'UPDATE briefings SET deleted_at = ? WHERE id = ?', args: [Date.now(), briefingId] })
24+
const check = await client.execute({ sql: 'SELECT id, deleted_at FROM briefings WHERE id = ?', args: [briefingId] })
25+
console.log('soft-deleted row:', check.rows)
26+
27+
// cleanup real (borra de verdad para no dejar basura de prueba)
28+
await client.execute({ sql: 'DELETE FROM briefing_items WHERE briefing_id = ?', args: [briefingId] })
29+
await client.execute({ sql: 'DELETE FROM briefings WHERE id = ?', args: [briefingId] })
30+
console.log('cleanup ok')

0 commit comments

Comments
 (0)