mirror of
https://github.com/correl/dejavu.git
synced 2024-11-27 11:09:51 +00:00
Added date track columns for songs and fingerprints and set named constraint for those tables.
This commit is contained in:
parent
f5ad848974
commit
ade00317f9
1 changed files with 21 additions and 14 deletions
|
@ -41,23 +41,30 @@ Queries:
|
||||||
# creates
|
# creates
|
||||||
CREATE_SONGS_TABLE = f"""
|
CREATE_SONGS_TABLE = f"""
|
||||||
CREATE TABLE IF NOT EXISTS `{SONGS_TABLENAME}` (
|
CREATE TABLE IF NOT EXISTS `{SONGS_TABLENAME}` (
|
||||||
`{FIELD_SONG_ID}` mediumint unsigned not null auto_increment,
|
`{FIELD_SONG_ID}` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT
|
||||||
`{FIELD_SONGNAME}` varchar(250) not null,
|
, `{FIELD_SONGNAME}` VARCHAR(250) NOT NULL
|
||||||
`{FIELD_FINGERPRINTED}` tinyint default 0,
|
, `{FIELD_FINGERPRINTED}` TINYINT DEFAULT 0
|
||||||
`{FIELD_FILE_SHA1}` binary(20) not null,
|
, `{FIELD_FILE_SHA1}` BINARY(20) NOT NULL
|
||||||
PRIMARY KEY (`{FIELD_SONG_ID}`),
|
, `date_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
UNIQUE KEY `{FIELD_SONG_ID}` (`{FIELD_SONG_ID}`)
|
, `date_modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
) ENGINE=INNODB;"""
|
, CONSTRAINT `pk_{SONGS_TABLENAME}_{FIELD_SONG_ID}` PRIMARY KEY (`{FIELD_SONG_ID}`)
|
||||||
|
, CONSTRAINT `uq_{SONGS_TABLENAME}_{FIELD_SONG_ID}` UNIQUE KEY (`{FIELD_SONG_ID}`)
|
||||||
|
) ENGINE=INNODB;
|
||||||
|
"""
|
||||||
|
|
||||||
CREATE_FINGERPRINTS_TABLE = f"""
|
CREATE_FINGERPRINTS_TABLE = f"""
|
||||||
CREATE TABLE IF NOT EXISTS `{FINGERPRINTS_TABLENAME}` (
|
CREATE TABLE IF NOT EXISTS `{FINGERPRINTS_TABLENAME}` (
|
||||||
`{FIELD_HASH}` binary(10) not null,
|
`{FIELD_HASH}` BINARY(10) NOT NULL
|
||||||
`{FIELD_SONG_ID}` mediumint unsigned not null,
|
, `{FIELD_SONG_ID}` MEDIUMINT UNSIGNED NOT NULL
|
||||||
`{FIELD_OFFSET}` int unsigned not null,
|
, `{FIELD_OFFSET}` INT UNSIGNED NOT NULL
|
||||||
INDEX ({FIELD_HASH}),
|
, `date_created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
UNIQUE KEY `unique_constraint` ({FIELD_SONG_ID}, {FIELD_OFFSET}, {FIELD_HASH}),
|
, `date_modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
FOREIGN KEY ({FIELD_SONG_ID}) REFERENCES {SONGS_TABLENAME}({FIELD_SONG_ID}) ON DELETE CASCADE
|
, INDEX ({FIELD_HASH})
|
||||||
) ENGINE=INNODB;"""
|
, CONSTRAINT `uq_{FINGERPRINTS_TABLENAME}` UNIQUE KEY ({FIELD_SONG_ID}, {FIELD_OFFSET}, {FIELD_HASH})
|
||||||
|
, CONSTRAINT `fk_{FINGERPRINTS_TABLENAME}_{FIELD_SONG_ID}` FOREIGN KEY ({FIELD_SONG_ID})
|
||||||
|
REFERENCES {SONGS_TABLENAME}({FIELD_SONG_ID}) ON DELETE CASCADE
|
||||||
|
) ENGINE=INNODB;
|
||||||
|
"""
|
||||||
|
|
||||||
# inserts (ignores duplicates)
|
# inserts (ignores duplicates)
|
||||||
INSERT_FINGERPRINT = f"""
|
INSERT_FINGERPRINT = f"""
|
||||||
|
|
Loading…
Reference in a new issue