mirror of
https://github.com/SinTan1729/chhoto-url
synced 2025-04-27 19:46:52 -05:00
chg: Move the uniqueness validation to the INDEX
This commit is contained in:
parent
b2bc2c450b
commit
88ddb4299a
1 changed files with 2 additions and 2 deletions
|
@ -92,7 +92,7 @@ pub fn open_db(path: String) -> Connection {
|
|||
"CREATE TABLE IF NOT EXISTS urls (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
long_url TEXT NOT NULL,
|
||||
short_url TEXT NOT NULL UNIQUE,
|
||||
short_url TEXT NOT NULL,
|
||||
hits INTEGER NOT NULL
|
||||
)",
|
||||
[],
|
||||
|
@ -101,7 +101,7 @@ pub fn open_db(path: String) -> Connection {
|
|||
|
||||
// Create index on short_url for faster lookups
|
||||
db.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_short_url ON urls (short_url)",
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS idx_short_url ON urls (short_url)",
|
||||
[],
|
||||
)
|
||||
.expect("Unable to create index on short_url.");
|
||||
|
|
Loading…
Reference in a new issue