From d25a1589dd3208f8bad47102d43879570ed103fe Mon Sep 17 00:00:00 2001 From: Briana Torres Date: Wed, 31 Jan 2024 18:56:56 -0500 Subject: [PATCH 1/2] created table and dummy data --- .vscode/settings.json | 14 ++++++++++++++ backend/go.mod | 2 +- backend/src/db/migrations/init.sql | 21 ++++++++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..215398d3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "sqltools.connections": [ + { + "previewLimit": 50, + "server": "localhost", + "port": 5432, + "askForPassword": true, + "driver": "PostgreSQL", + "name": "bri", + "username": "bri", + "database": "briana" + } + ] +} \ No newline at end of file diff --git a/backend/go.mod b/backend/go.mod index 096ab295..6a75b7e5 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -8,6 +8,7 @@ require ( github.com/spf13/viper v1.18.2 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 + github.com/swaggo/swag v1.16.2 gorm.io/driver/postgres v1.5.4 gorm.io/gorm v1.25.5 ) @@ -63,7 +64,6 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/swaggo/swag v1.16.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/urfave/cli/v2 v2.27.1 // indirect diff --git a/backend/src/db/migrations/init.sql b/backend/src/db/migrations/init.sql index 5d2ffcb2..04b84360 100644 --- a/backend/src/db/migrations/init.sql +++ b/backend/src/db/migrations/init.sql @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS users; +DROP TABLE IF EXISTS following; CREATE TABLE IF NOT EXISTS users ( user_id SERIAL PRIMARY KEY, @@ -12,4 +13,22 @@ CREATE TABLE IF NOT EXISTS users ( INSERT INTO users (first_name, last_name, pass_word, email) VALUES ('Ania', 'Misiorek', 'password', 'email1@gmail.com'), - ('Leroy', 'Shaigorodsky', 'password', 'email2@gmail.com'); \ No newline at end of file + ('Leroy', 'Shaigorodsky', 'password', 'email2@gmail.com'); + +CREATE TABLE IF NOT EXISTS following ( + following_id SERIAL PRIMARY KEY, + follower_user_id INT NOT NULL REFERENCES users(user_id), + following_user_id INT NOT NULL REFERENCES users(user_id), + follow_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + CONSTRAINT unique_following_pair UNIQUE (follower_user_id, following_user_id), + CONSTRAINT no_self_follow CHECK (follower_user_id != following_user_id) +); + +CREATE INDEX IF NOT EXISTS idx_follower_user_id ON following(follower_user_id); +CREATE INDEX IF NOT EXISTS idx_following_user_id ON following(following_user_id); + +-- Insert sample data into "following" table +INSERT INTO following (follower_user_id, following_user_id) +VALUES + (1, 2), + (2, 1); From c05b86ed1543ac1857eda82dbe9e57810c8236ac Mon Sep 17 00:00:00 2001 From: leoRysing Date: Fri, 2 Feb 2024 13:08:11 -0500 Subject: [PATCH 2/2] removing vscode from push for now (settings saved in case needed) --- .vscode/settings.json | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 215398d3..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "sqltools.connections": [ - { - "previewLimit": 50, - "server": "localhost", - "port": 5432, - "askForPassword": true, - "driver": "PostgreSQL", - "name": "bri", - "username": "bri", - "database": "briana" - } - ] -} \ No newline at end of file