mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-09 16:44:21 +01:00
create tags_usages kysely table
This commit is contained in:
@@ -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;
|
||||
|
||||
28
src/db/migrations/021_create_trends.ts
Normal file
28
src/db/migrations/021_create_trends.ts
Normal file
@@ -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();
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user