Fix unique constraint hit
For HN reposts, the same SN dupe was found but since sn_items.id was the primary key, a unique constraint was hit. This meant that posting the same item was attempted over and over again since the HN item id was never found in sn_items. I manually migrated the database.
This commit is contained in:
parent
0a0470ae67
commit
cc5a05574a
5
db.go
5
db.go
|
@ -41,9 +41,10 @@ func migrate(db *sql.DB) {
|
||||||
}
|
}
|
||||||
if _, err := db.Exec(`
|
if _, err := db.Exec(`
|
||||||
CREATE TABLE IF NOT EXISTS sn_items (
|
CREATE TABLE IF NOT EXISTS sn_items (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER NOT NULL,
|
||||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
hn_id INTEGER NOT NULL REFERENCES hn_items(id)
|
hn_id INTEGER NOT NULL REFERENCES hn_items(id),
|
||||||
|
PRIMARY KEY (id, hn_id)
|
||||||
);
|
);
|
||||||
`); err != nil {
|
`); err != nil {
|
||||||
err = fmt.Errorf("error during migration: %w", err)
|
err = fmt.Errorf("error during migration: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue