mainly functional matching

This commit is contained in:
2025-09-18 11:42:18 +09:00
parent e275a9856b
commit 85027a7747
15 changed files with 1179 additions and 77 deletions

View File

@@ -0,0 +1,44 @@
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';
export const shorthands: ColumnDefinitions | undefined = undefined;
export async function up(pgm: MigrationBuilder): Promise<void> {
// Создание таблицы profile_views для хранения информации о просмотренных профилях
pgm.createTable('profile_views', {
id: { type: 'uuid', primaryKey: true, default: pgm.func('uuid_generate_v4()') },
viewer_id: {
type: 'uuid',
notNull: true,
references: 'users',
onDelete: 'CASCADE'
},
viewed_profile_id: {
type: 'uuid',
notNull: true,
references: 'profiles(user_id)',
onDelete: 'CASCADE'
},
view_date: { type: 'timestamp', notNull: true, default: pgm.func('now()') },
view_type: { type: 'varchar(20)', notNull: true, default: 'browse' }, // browse, match, like, etc.
});
// Создание индекса для быстрого поиска по паре (просмотревший - просмотренный)
pgm.createIndex('profile_views', ['viewer_id', 'viewed_profile_id'], {
unique: true,
name: 'profile_views_viewer_viewed_idx'
});
// Индекс для быстрого поиска по viewer_id
pgm.createIndex('profile_views', ['viewer_id'], {
name: 'profile_views_viewer_idx'
});
// Индекс для быстрого поиска по viewed_profile_id
pgm.createIndex('profile_views', ['viewed_profile_id'], {
name: 'profile_views_viewed_idx'
});
}
export async function down(pgm: MigrationBuilder): Promise<void> {
pgm.dropTable('profile_views', { cascade: true });
}