created by for sermons
This commit is contained in:
@@ -14,6 +14,7 @@ export interface Sermon {
|
||||
personal_appliance: string
|
||||
pastors_challenge: string
|
||||
worship_songs?: string
|
||||
created_by?: string
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
@@ -77,10 +78,18 @@ export function getDatabase() {
|
||||
personal_appliance TEXT NOT NULL,
|
||||
pastors_challenge TEXT NOT NULL,
|
||||
worship_songs TEXT,
|
||||
created_by TEXT,
|
||||
archived INTEGER DEFAULT 0,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
created_at DATETIME DEFAULT CURRENT TIMESTAMP
|
||||
)
|
||||
`)
|
||||
|
||||
// Add created_by column if it doesn't exist (migration)
|
||||
try {
|
||||
db.exec(`ALTER TABLE sermons ADD COLUMN created_by TEXT`)
|
||||
} catch (e) {
|
||||
// Column already exists, ignore error
|
||||
}
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
@@ -184,8 +193,8 @@ export function getSermonBySlug(slug: string) {
|
||||
export function createSermon(sermon: Sermon) {
|
||||
const db = getDatabase()
|
||||
const stmt = db.prepare(`
|
||||
INSERT INTO sermons (slug, title, date, dates, bible_references, personal_appliance, pastors_challenge, worship_songs)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO sermons (slug, title, date, dates, bible_references, personal_appliance, pastors_challenge, worship_songs, created_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`)
|
||||
return stmt.run(
|
||||
sermon.slug,
|
||||
@@ -195,7 +204,8 @@ export function createSermon(sermon: Sermon) {
|
||||
sermon.bible_references,
|
||||
sermon.personal_appliance,
|
||||
sermon.pastors_challenge,
|
||||
sermon.worship_songs || null
|
||||
sermon.worship_songs || null,
|
||||
sermon.created_by || null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user