feat: create initial database schema

This commit is contained in:
Bastien Riviere 2024-01-29 19:32:01 +01:00
parent 00bd014cdd
commit 875a6d1a33
Signed by: babariviere
GPG key ID: 4E5F0839249F162E
11 changed files with 155 additions and 0 deletions

View file

@ -0,0 +1,4 @@
-- Create "urls" table
CREATE TABLE "public"."urls" ("id" serial NOT NULL, "hash" text NOT NULL, "long_url" text NOT NULL, PRIMARY KEY ("id"));
-- Create index "urls_hash_key" to table: "urls"
CREATE UNIQUE INDEX "urls_hash_key" ON "public"."urls" ("hash");

2
sql/migrations/atlas.sum Normal file
View file

@ -0,0 +1,2 @@
h1:iaq5N24NlZigxTmAlrTtB5kyXb52a+gVSEHYpfgvvwE=
20240129183014_create_url_table.sql h1:k/l+yABFDePCCXnnZ4OM9k47oE4CdvvN6tjSCZelAo0=

3
sql/query.sql Normal file
View file

@ -0,0 +1,3 @@
-- name: GetURLByHash :one
SELECT * FROM urls
WHERE hash = $1;

5
sql/schema.sql Normal file
View file

@ -0,0 +1,5 @@
CREATE TABLE urls (
id SERIAL PRIMARY KEY,
hash TEXT NOT NULL UNIQUE,
long_url TEXT NOT NULL
);