magneticod: use mysql in strict mode, increase name column to 1024 characters
This commit is contained in:
parent
1123c948f9
commit
90fad55722
@ -229,11 +229,17 @@ func setupSqliteDatabase(database *sql.DB) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupMySQLDatabase(database *sql.DB) error {
|
func setupMySQLDatabase(database *sql.DB) error {
|
||||||
_, err := database.Exec(
|
// Set strict mode to prevent silent truncation
|
||||||
|
_, err := database.Exec(`SET SESSION SQL_MODE = 'STRICT_ALL_TABLES';`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = database.Exec(
|
||||||
`CREATE TABLE IF NOT EXISTS torrents ("
|
`CREATE TABLE IF NOT EXISTS torrents ("
|
||||||
id INTEGER PRIMARY KEY AUTO_INCREMENT,
|
id INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||||
info_hash BINARY(20) NOT NULL UNIQUE,
|
info_hash BINARY(20) NOT NULL UNIQUE,
|
||||||
name VARCHAR(255) NOT NULL,
|
name VARCHAR(1024) NOT NULL,
|
||||||
total_size BIGINT UNSIGNED NOT NULL,
|
total_size BIGINT UNSIGNED NOT NULL,
|
||||||
discovered_on INTEGER UNSIGNED NOT NULL
|
discovered_on INTEGER UNSIGNED NOT NULL
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user