Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #1

Open
wants to merge 10 commits into
base: aulas
Choose a base branch
from
Open

V2 #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NODE_ENV=test
DATABASE_URL="postgresql://docker:docker@localhost:5432/inorbit_test"

GITHUB_OAUTH_CLIENT_ID=""
GITHUB_OAUTH_CLIENT_SECRET=""

JWT_SECRET=12ofwejkgv890evhj8hsduiqhfi23
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Run tests

on: push

jobs:
run-ci:
name: Run E2E Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
ports:
- 5432:5432
env:
POSTGRES_USER: docker
POSTGRES_PASSWORD: docker
POSTGRES_DB: inorbit_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- run: npm ci
- run: npm run test
7 changes: 7 additions & 0 deletions .migrations/0002_ordinary_lilandra.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS "users" (
"id" text PRIMARY KEY NOT NULL,
"name" text,
"email" text NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "users_email_unique" UNIQUE("email")
);
4 changes: 4 additions & 0 deletions .migrations/0003_gray_marten_broadcloak.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE "users" DROP CONSTRAINT "users_email_unique";--> statement-breakpoint
ALTER TABLE "users" ALTER COLUMN "email" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "external_account_id" text NOT NULL;--> statement-breakpoint
ALTER TABLE "users" ADD CONSTRAINT "users_external_account_id_unique" UNIQUE("external_account_id");
1 change: 1 addition & 0 deletions .migrations/0004_milky_sentinel.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "users" ADD COLUMN "avatar_url" text NOT NULL;
2 changes: 2 additions & 0 deletions .migrations/0005_watery_ben_urich.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "users" DROP COLUMN "external_account_id";
ALTER TABLE "users" ADD COLUMN "external_account_id" integer NOT NULL;
6 changes: 6 additions & 0 deletions .migrations/0006_smooth_speed_demon.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE "goals" ADD COLUMN "user_id" text NOT NULL;--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "goals" ADD CONSTRAINT "goals_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
2 changes: 2 additions & 0 deletions .migrations/0007_brainy_gamora.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "users" ADD COLUMN "experience" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "level" integer DEFAULT 1 NOT NULL;
1 change: 1 addition & 0 deletions .migrations/0008_magenta_supreme_intelligence.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "users" DROP COLUMN IF EXISTS "level";
137 changes: 137 additions & 0 deletions .migrations/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"id": "6a61e373-84ce-4133-a492-fecc733eac6e",
"prevId": "a0d658ee-e5b3-4793-95ce-2c0c7363ea7f",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.goal_completions": {
"name": "goal_completions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"goal_id": {
"name": "goal_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"goal_completions_goal_id_goals_id_fk": {
"name": "goal_completions_goal_id_goals_id_fk",
"tableFrom": "goal_completions",
"tableTo": "goals",
"columnsFrom": [
"goal_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.goals": {
"name": "goals",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"desired_weekly_frequency": {
"name": "desired_weekly_frequency",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_email_unique": {
"name": "users_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
143 changes: 143 additions & 0 deletions .migrations/meta/0003_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"id": "21b85a1f-a180-4952-9bcf-4bb4c7a355a6",
"prevId": "6a61e373-84ce-4133-a492-fecc733eac6e",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.goal_completions": {
"name": "goal_completions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"goal_id": {
"name": "goal_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"goal_completions_goal_id_goals_id_fk": {
"name": "goal_completions_goal_id_goals_id_fk",
"tableFrom": "goal_completions",
"tableTo": "goals",
"columnsFrom": [
"goal_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.goals": {
"name": "goals",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"desired_weekly_frequency": {
"name": "desired_weekly_frequency",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": false
},
"external_account_id": {
"name": "external_account_id",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"users_external_account_id_unique": {
"name": "users_external_account_id_unique",
"nullsNotDistinct": false,
"columns": [
"external_account_id"
]
}
}
}
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
Loading