Added fingerprint table and WIP StashDB import tool.
This commit is contained in:
66
migrations/20260125052234_fingerprints.js
Normal file
66
migrations/20260125052234_fingerprints.js
Normal file
@@ -0,0 +1,66 @@
|
||||
const config = require('config');
|
||||
|
||||
exports.up = async (knex) => {
|
||||
await knex.schema.createTable('fingerprints_types', (table) => {
|
||||
table.string('type')
|
||||
.primary();
|
||||
});
|
||||
|
||||
await knex('fingerprints_types').insert([
|
||||
'oshash',
|
||||
'phash',
|
||||
'md5',
|
||||
'blake2',
|
||||
].map((type) => ({ type })));
|
||||
|
||||
await knex.schema.createTable('releases_fingerprints', (table) => {
|
||||
table.increments('id');
|
||||
|
||||
table.integer('scene_id')
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('releases');
|
||||
|
||||
table.string('hash')
|
||||
.notNullable()
|
||||
.index();
|
||||
|
||||
table.string('type')
|
||||
.notNullable()
|
||||
.references('type')
|
||||
.inTable('fingerprints_types');
|
||||
|
||||
table.integer('duration');
|
||||
table.integer('width');
|
||||
table.integer('height');
|
||||
|
||||
table.integer('user_id')
|
||||
.references('id')
|
||||
.inTable('users');
|
||||
|
||||
table.string('source');
|
||||
table.integer('source_submissions');
|
||||
table.json('source_meta');
|
||||
|
||||
table.datetime('source_created_at');
|
||||
|
||||
table.datetime('created_at')
|
||||
.notNullable()
|
||||
.defaultTo(knex.fn.now());
|
||||
});
|
||||
|
||||
await knex.raw(`
|
||||
create unique index scenes_fingerprints_unique
|
||||
on releases_fingerprints (scene_id, hash, source, user_id)
|
||||
nulls not distinct
|
||||
`);
|
||||
|
||||
await knex.raw('GRANT ALL ON ALL TABLES IN SCHEMA public TO :visitor;', {
|
||||
visitor: knex.raw(config.database.query.user),
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = async function(knex) {
|
||||
await knex.schema.dropTable('releases_fingerprints');
|
||||
await knex.schema.dropTable('fingerprints_types');
|
||||
};
|
||||
Reference in New Issue
Block a user