mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
create tags_usages kysely table
This commit is contained in:
parent
8c46560df4
commit
83a7b1f231
2 changed files with 35 additions and 0 deletions
|
|
@ -6,8 +6,15 @@ export interface DittoTables {
|
||||||
author_stats: AuthorStatsRow;
|
author_stats: AuthorStatsRow;
|
||||||
event_stats: EventStatsRow;
|
event_stats: EventStatsRow;
|
||||||
pubkey_domains: PubkeyDomainRow;
|
pubkey_domains: PubkeyDomainRow;
|
||||||
|
trends_tag_usages: TagUsageRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TagUsageRow {
|
||||||
|
tag: string,
|
||||||
|
pubkey8: string,
|
||||||
|
inserted_at: number
|
||||||
|
};
|
||||||
|
|
||||||
interface AuthorStatsRow {
|
interface AuthorStatsRow {
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
followers_count: number;
|
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();
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue