A very performant and light (2mb in memory) link shortener and tracker. Written in Rust and React and uses Postgres/SQLite.
1-- Add Migration Version 2CREATE TABLE IF NOT EXISTS _sqlx_migrations ( 3 version BIGINT PRIMARY KEY, 4 description TEXT NOT NULL, 5 installed_on TIMESTAMPTZ NOT NULL DEFAULT NOW() 6); 7 8-- Create users table 9CREATE TABLE users ( 10 id SERIAL PRIMARY KEY, 11 email VARCHAR(255) NOT NULL UNIQUE, 12 password_hash TEXT NOT NULL 13); 14 15-- Create links table 16CREATE TABLE links ( 17 id SERIAL PRIMARY KEY, 18 original_url TEXT NOT NULL, 19 short_code VARCHAR(8) NOT NULL UNIQUE, 20 created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), 21 clicks BIGINT NOT NULL DEFAULT 0, 22 user_id INTEGER REFERENCES users(id) 23); 24 25-- Create clicks table 26CREATE TABLE clicks ( 27 id SERIAL PRIMARY KEY, 28 link_id INTEGER REFERENCES links(id), 29 source TEXT, 30 query_source TEXT, 31 created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() 32); 33 34-- Create indexes 35CREATE INDEX idx_short_code ON links(short_code); 36CREATE INDEX idx_user_id ON links(user_id); 37CREATE INDEX idx_link_id ON clicks(link_id);