mirror of
https://github.com/andwati/url-shortener.git
synced 2026-10-18 10:42:52 +00:00
13 lines
330 B
SQL
13 lines
330 B
SQL
CREATE DATABASE urlshortener;
|
|
|
|
\c urlshortener
|
|
|
|
CREATE TABLE IF NOT EXISTS urls(
|
|
id SERIAL PRIMARY KEY,
|
|
original_url TEXT NOT NULL,
|
|
short_code VARCHAR(10) UNIQUE NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
visits INTEGER DEFAULT 0
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_short_code ON urls(short_code) |