import Database from 'better-sqlite3';
-import {RSSParser} from 'src/parsers/rss';
-import { v4 as uuidv4 } from 'uuid';
+import { cli } from './migrate';
const DB = 'feeds.db';
export const writer = new Database(DB, {
verbose: console.log
});
+export function down() {
+ writer.prepare('drop table feed_items').run();
+ writer.prepare('drop table feedlist').run();
+ writer.prepare('drop table accounts').run();
+}
+
+export function up() {
+ writer.prepare(`
+ create table accounts (
+ id text unique,
+ email text unique,
+ signup_date number,
+ login_code text,
+ login_code_expires number
+ )
+ `).run();
-writer.prepare('drop table if exists feed_items').run();
-writer.prepare('drop table feedlist').run();
writer.prepare(`
create table feedlist (
id text unique,
+ account_id text,
title text,
- link text unique
+ link text
)
`).run();
+writer.prepare(`create index idx_account_feed on feedlist (account_id, link)`).run();
writer.prepare(`
)
`).run();
+}
+/*
const feeds = [
{
id: uuidv4(),
insert.run(id, feed.id, item.guid, item.title, item.link, item.pubDate, item.content);
});
});
+*/
+const args = cli(process.argv);
+if(args.dir === 'up') {
+ up();
+}
+else if(args.dir === 'down') {
+ down();
+}
+else {
+ console.error('Invalid dir');
+ process.exit(1);
+}
+
+process.exit(0);