create tags_usages kysely table
This commit is contained in:
parent
8c46560df4
commit
83a7b1f231
|
@ -6,8 +6,15 @@ export interface DittoTables {
|
|||
author_stats: AuthorStatsRow;
|
||||
event_stats: EventStatsRow;
|
||||
pubkey_domains: PubkeyDomainRow;
|
||||
trends_tag_usages: TagUsageRow;
|
||||
}
|
||||
|
||||
interface TagUsageRow {
|
||||
tag: string,
|
||||
pubkey8: string,
|
||||
inserted_at: number
|
||||
};
|
||||
|
||||
interface AuthorStatsRow {
|
||||
pubkey: string;
|
||||
followers_count: number;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.transaction().execute(async trx => {
|
||||
await trx.schema
|
||||
.createTable('trends_tag_usages')
|
||||
.ifNotExists()
|
||||
.addColumn('tag', 'text', c => c.notNull().modifyEnd(sql`collate nocase`))
|
||||
.addColumn('pubkey8', 'text', c => c.notNull())
|
||||
.addColumn('inserted_at', 'integer', c => c.notNull())
|
||||
.execute();
|
||||
|
||||
await trx.schema
|
||||
.createIndex('trends_idx_time_tag')
|
||||
.ifNotExists()
|
||||
.on('trends_tag_usages')
|
||||
.column('inserted_at')
|
||||
.column('tag')
|
||||
.execute();
|
||||
})
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.transaction().execute(async trx => {
|
||||
await trx.schema.dropIndex('trends_idx_time_tag').ifExists().execute();
|
||||
await trx.schema.dropTable('trends_tag_usages').ifExists().execute();
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue