1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2025-05-01 05:06:52 -05:00
This commit is contained in:
magnus 2025-04-18 20:27:38 +02:00 committed by GitHub
commit 32f18ebd21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -92,12 +92,19 @@ 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,
short_url TEXT NOT NULL UNIQUE,
hits INTEGER NOT NULL
)",
[],
)
.expect("Unable to initialize empty database.");
// Create index on short_url for faster lookups
db.execute(
"CREATE INDEX IF NOT EXISTS idx_short_url ON urls (short_url)",
[],
)
.expect("Unable to create index on short_url.");
db
}