-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateTestDb.cjs
More file actions
31 lines (27 loc) · 920 Bytes
/
createTestDb.cjs
File metadata and controls
31 lines (27 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const sqlite3 = require('sqlite3').verbose()
const db = new sqlite3.Database('./db.test.sqlite')
db.serialize(() => {
// drop old table
db.run('DROP TABLE IF EXISTS blogPosts')
// create new table
db.run(`CREATE TABLE IF NOT EXISTS blogPosts (
id INTEGER PRIMARY KEY,
slug TEXT,
content TEXT,
title TEXT,
date DATE,
headerImage TEXT,
thumbnailImage TEXT,
tags TEXT,
deleted INTEGER,
byline TEXT
)`)
// drop old users table
db.run('DROP TABLE IF EXISTS users')
// create new users table
db.run('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username TEXT, passwordHash TEXT)')
// drop old emails table
db.run('DROP TABLE IF EXISTS emails')
// create emails table
db.run('CREATE TABLE IF NOT EXISTS emails (id INTEGER PRIMARY KEY, email TEXT, dateRegistered DATE)')
})