From 1fb77d4e6ab870dbcd92249e720707d8f8ee2ffc Mon Sep 17 00:00:00 2001
From: rfhferreira <rfhferreira@inf.ufpr.br>
Date: Tue, 20 May 2025 12:03:57 -0300
Subject: [PATCH] Correct schema

---
 ...ffy_sentinel.sql => 0000_burly_terror.sql} |  8 +++----
 src/db/migrations/meta/0000_snapshot.json     | 22 ++++---------------
 src/db/migrations/meta/_journal.json          |  4 ++--
 src/db/schema/resource.schema.ts              |  4 ++--
 src/db/schema/user.schema.ts                  |  8 ++-----
 5 files changed, 13 insertions(+), 33 deletions(-)
 rename src/db/migrations/{0000_daffy_sentinel.sql => 0000_burly_terror.sql} (99%)

diff --git a/src/db/migrations/0000_daffy_sentinel.sql b/src/db/migrations/0000_burly_terror.sql
similarity index 99%
rename from src/db/migrations/0000_daffy_sentinel.sql
rename to src/db/migrations/0000_burly_terror.sql
index f19b960..3018838 100644
--- a/src/db/migrations/0000_daffy_sentinel.sql
+++ b/src/db/migrations/0000_burly_terror.sql
@@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS "resources" (
 	"state" "resource_state" DEFAULT 'draft' NOT NULL,
 	"name" varchar(255) NOT NULL,
 	"author" varchar(255) NOT NULL,
-	"link" varchar(255),
+	"link" varchar(1024),
 	"thumbnail" varchar(255),
 	"description" text,
 	"created_at" timestamp DEFAULT now() NOT NULL,
@@ -348,10 +348,10 @@ CREATE TABLE IF NOT EXISTS "users" (
 	"name" varchar(255) NOT NULL,
 	"username" varchar(255),
 	"password" varchar(255),
-	"email" varchar(255) NOT NULL,
+	"email" varchar(255),
 	"description" text DEFAULT 'sem descrição',
 	"birthday" timestamp,
-	"cpf" varchar(11) NOT NULL,
+	"cpf" varchar(11),
 	"created_at" timestamp DEFAULT now() NOT NULL,
 	"updated_at" timestamp DEFAULT now() NOT NULL,
 	"confirmed_at" timestamp,
@@ -366,8 +366,6 @@ CREATE TABLE IF NOT EXISTS "users" (
 	"level_xp" integer DEFAULT 0,
 	CONSTRAINT "users_id_unique" UNIQUE("id"),
 	CONSTRAINT "users_username_unique" UNIQUE("username"),
-	CONSTRAINT "users_email_unique" UNIQUE("email"),
-	CONSTRAINT "users_cpf_unique" UNIQUE("cpf"),
 	CONSTRAINT "users_user_stats_id_unique" UNIQUE("user_stats_id")
 );
 --> statement-breakpoint
diff --git a/src/db/migrations/meta/0000_snapshot.json b/src/db/migrations/meta/0000_snapshot.json
index 614bf45..bdcaa27 100644
--- a/src/db/migrations/meta/0000_snapshot.json
+++ b/src/db/migrations/meta/0000_snapshot.json
@@ -1,5 +1,5 @@
 {
-  "id": "17e5bf00-dd96-41e3-bf35-afd7c7d13881",
+  "id": "f2e2d3b9-e896-4124-9747-59bff364742e",
   "prevId": "00000000-0000-0000-0000-000000000000",
   "version": "7",
   "dialect": "postgresql",
@@ -1704,7 +1704,7 @@
         },
         "link": {
           "name": "link",
-          "type": "varchar(255)",
+          "type": "varchar(1024)",
           "primaryKey": false,
           "notNull": false
         },
@@ -2517,7 +2517,7 @@
           "name": "email",
           "type": "varchar(255)",
           "primaryKey": false,
-          "notNull": true
+          "notNull": false
         },
         "description": {
           "name": "description",
@@ -2536,7 +2536,7 @@
           "name": "cpf",
           "type": "varchar(11)",
           "primaryKey": false,
-          "notNull": true
+          "notNull": false
         },
         "created_at": {
           "name": "created_at",
@@ -2650,20 +2650,6 @@
             "username"
           ]
         },
-        "users_email_unique": {
-          "name": "users_email_unique",
-          "nullsNotDistinct": false,
-          "columns": [
-            "email"
-          ]
-        },
-        "users_cpf_unique": {
-          "name": "users_cpf_unique",
-          "nullsNotDistinct": false,
-          "columns": [
-            "cpf"
-          ]
-        },
         "users_user_stats_id_unique": {
           "name": "users_user_stats_id_unique",
           "nullsNotDistinct": false,
diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json
index 1487bcc..3fe686d 100644
--- a/src/db/migrations/meta/_journal.json
+++ b/src/db/migrations/meta/_journal.json
@@ -5,8 +5,8 @@
     {
       "idx": 0,
       "version": "7",
-      "when": 1747659017843,
-      "tag": "0000_daffy_sentinel",
+      "when": 1747750392448,
+      "tag": "0000_burly_terror",
       "breakpoints": true
     }
   ]
diff --git a/src/db/schema/resource.schema.ts b/src/db/schema/resource.schema.ts
index 2eb013b..cfa5a81 100644
--- a/src/db/schema/resource.schema.ts
+++ b/src/db/schema/resource.schema.ts
@@ -28,7 +28,7 @@ const resourceTable = pgTable('resources', {
     .notNull(),
   author: varchar('author', { length: 255 })
     .notNull(),
-  link: varchar('link', { length: 255 }),
+  link: varchar('link', { length: 1024 }),
   thumbnail: varchar('thumbnail', { length: 255 }),
   description: text('description'),
   created_at: timestamp('created_at', { mode: 'string' })
@@ -100,4 +100,4 @@ export const resourceSchema = {
   return: resourceReturnSchema
 }
 
-export default resourceTable
\ No newline at end of file
+export default resourceTable
diff --git a/src/db/schema/user.schema.ts b/src/db/schema/user.schema.ts
index a8ed8be..755a2a9 100644
--- a/src/db/schema/user.schema.ts
+++ b/src/db/schema/user.schema.ts
@@ -13,15 +13,11 @@ const userTable = pgTable('users', {
   username: varchar('username', { length: 255 })
     .unique(),
   password: varchar('password', { length: 255 }),
-  email: varchar('email', { length: 255 })
-    .unique()
-    .notNull(),
+  email: varchar('email', { length: 255 }),
   description: text('description')
     .default("sem descrição"),
   birthday: timestamp('birthday', { mode: 'string' }),
-  cpf: varchar('cpf', { length: 11 })
-    .unique()
-    .notNull(),
+  cpf: varchar('cpf', { length: 11 }),
   createdAt: timestamp('created_at', { mode: 'string' })
     .notNull()
     .defaultNow(),
-- 
GitLab