From 4ec93218b931505b6b055a03f624ff4c651c1230 Mon Sep 17 00:00:00 2001 From: Thiago Souza Da Silva Date: Fri, 18 Sep 2026 15:30:47 -0300 Subject: [PATCH 1/5] feat: cria a tabela knex da campanha, vaquinha e rifa --- back/package-lock.json | 1 + .../migrations/20260912221551_campanhas.ts | 26 ++++++++++++++++--- .../migrations/20260912221614_vaquinhas.ts | 17 +++++++++--- .../migrations/20260912221623_rifas.ts | 17 +++++++++--- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/back/package-lock.json b/back/package-lock.json index 881d631..692ad16 100644 --- a/back/package-lock.json +++ b/back/package-lock.json @@ -1788,6 +1788,7 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.23.0.tgz", "integrity": "sha512-Ip2EQCngowJLGOfCwkFhPXU7/ljlhn6Rxlmy4XYfL2Y+vyRM59+8uR2xqRWKdYmbXmxCFOAmKxBuSUCdF34qLg==", "license": "MIT", + "peer": true, "dependencies": { "pg-connection-string": "^2.14.0", "pg-pool": "^3.14.0", diff --git a/back/src/database/migrations/20260912221551_campanhas.ts b/back/src/database/migrations/20260912221551_campanhas.ts index 9270377..8dec5a6 100644 --- a/back/src/database/migrations/20260912221551_campanhas.ts +++ b/back/src/database/migrations/20260912221551_campanhas.ts @@ -1,10 +1,28 @@ -import type { Knex } from "knex"; - +import { Knex } from "knex"; export async function up(knex: Knex): Promise { -} + return knex.schema.createTable("campaigns", (table: Knex.CreateTableBuilder) => { + table.increments("id").primary(); + table.string("public_id", 36).notNullable().unique(); + table.string("title", 255).notNullable(); + table.text("description").nullable(); + table.string("pix_key", 255).notNullable(); + table.string("visibility", 20).notNullable(); + table.string("status", 20).notNullable(); + table.string("category", 20).notNullable(); + table.date("start_date").notNullable(); + table.date("end_date").notNullable(); + + table.integer("organizer_id").unsigned().notNullable().references("id").inTable("organizers").onDelete("CASCADE"); + + table.timestamp("created_at").defaultTo(knex.fn.now()); + }); -export async function down(knex: Knex): Promise { } +export async function down(knex: Knex): Promise { + + return knex.schema.dropTableIfExists("campaigns"); + +} \ No newline at end of file diff --git a/back/src/database/migrations/20260912221614_vaquinhas.ts b/back/src/database/migrations/20260912221614_vaquinhas.ts index 9270377..9d20ab8 100644 --- a/back/src/database/migrations/20260912221614_vaquinhas.ts +++ b/back/src/database/migrations/20260912221614_vaquinhas.ts @@ -1,10 +1,21 @@ -import type { Knex } from "knex"; +import { Knex } from "knex"; + export async function up(knex: Knex): Promise { -} + return knex.schema.createTable("crowdfundings", (table) => { + table.increments("id").primary(); + + + table.decimal("raised_amount", 10, 2).defaultTo(0.00); + table.integer("campaign_id").unsigned().notNullable().references("id").inTable("campaigns").onDelete("CASCADE"); -export async function down(knex: Knex): Promise { + }); } +export async function down(knex: Knex): Promise { + + return knex.schema.dropTableIfExists("crowdfundings"); + +} \ No newline at end of file diff --git a/back/src/database/migrations/20260912221623_rifas.ts b/back/src/database/migrations/20260912221623_rifas.ts index 9270377..9aab965 100644 --- a/back/src/database/migrations/20260912221623_rifas.ts +++ b/back/src/database/migrations/20260912221623_rifas.ts @@ -1,10 +1,19 @@ -import type { Knex } from "knex"; - +import { Knex } from "knex"; export async function up(knex: Knex): Promise { -} + return knex.schema.createTable("raffles", (table) => { + table.increments("id").primary(); + table.string("location", 255).notNullable(); + table.string("prize", 255).notNullable(); -export async function down(knex: Knex): Promise { + table.integer("campaign_id").unsigned().notNullable().references("id").inTable("campaigns").onDelete("CASCADE"); + + }); } +export async function down(knex: Knex): Promise { + + return knex.schema.dropTableIfExists("raffles"); + +} \ No newline at end of file From 1c08b1a76a108f10c7fa20b6467711798bcd6281 Mon Sep 17 00:00:00 2001 From: Daniel Brito de Souza Date: Sun, 20 Sep 2026 16:15:56 -0300 Subject: [PATCH 2/5] add:tabelas: inscricao, redes sociais, user --- back/package-lock.json | 1 - back/src/database/migrations/20260911201457_user.ts | 13 +++++++++++-- .../migrations/20260912221823_redes_sociais.ts | 8 ++++++++ .../database/migrations/20260912221841_inscricao.ts | 8 ++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/back/package-lock.json b/back/package-lock.json index 692ad16..881d631 100644 --- a/back/package-lock.json +++ b/back/package-lock.json @@ -1788,7 +1788,6 @@ "resolved": "https://registry.npmjs.org/pg/-/pg-8.23.0.tgz", "integrity": "sha512-Ip2EQCngowJLGOfCwkFhPXU7/ljlhn6Rxlmy4XYfL2Y+vyRM59+8uR2xqRWKdYmbXmxCFOAmKxBuSUCdF34qLg==", "license": "MIT", - "peer": true, "dependencies": { "pg-connection-string": "^2.14.0", "pg-pool": "^3.14.0", diff --git a/back/src/database/migrations/20260911201457_user.ts b/back/src/database/migrations/20260911201457_user.ts index f8858f3..6a22c66 100644 --- a/back/src/database/migrations/20260911201457_user.ts +++ b/back/src/database/migrations/20260911201457_user.ts @@ -2,11 +2,20 @@ import type { Knex } from "knex"; export async function up(knex: Knex): Promise { - + return knex.schema.createTable('users', (table: Knex.CreateTableBuilder) => { + table.increments('id').primary(); + table.string('public_id', 36).notNullable().unique(); + table.string('name').notNullable(); + table.string('cellphone_number').notNullable().unique(); + table.string('email').notNullable().unique(); + table.string('password').notNullable(); + table.timestamp('created_at').defaultTo(knex.fn.now()); + table.timestamp('updated_at').defaultTo(knex.fn.now()); + }); } export async function down(knex: Knex): Promise { - + return knex.schema.dropTable('users'); } diff --git a/back/src/database/migrations/20260912221823_redes_sociais.ts b/back/src/database/migrations/20260912221823_redes_sociais.ts index 9270377..b095863 100644 --- a/back/src/database/migrations/20260912221823_redes_sociais.ts +++ b/back/src/database/migrations/20260912221823_redes_sociais.ts @@ -2,9 +2,17 @@ import type { Knex } from "knex"; export async function up(knex: Knex): Promise { + return knex.schema.createTable('social_networks', (table: Knex.CreateTableBuilder) => { + table.increments('id').primary(); + table.string('public_id', 36).notNullable().unique(); + table.integer('user_id').notNullable().references('id').inTable('users').onDelete('CASCADE'); + table.enum('platform', ['instagram', 'facebook', 'tiktok', 'youtube', 'x', 'other']).notNullable(); + table.text('url').notNullable(); + }); } export async function down(knex: Knex): Promise { + return knex.schema.dropTable('social_networks'); } diff --git a/back/src/database/migrations/20260912221841_inscricao.ts b/back/src/database/migrations/20260912221841_inscricao.ts index 9270377..8aef8e4 100644 --- a/back/src/database/migrations/20260912221841_inscricao.ts +++ b/back/src/database/migrations/20260912221841_inscricao.ts @@ -2,9 +2,17 @@ import type { Knex } from "knex"; export async function up(knex: Knex): Promise { + return knex.schema.createTable('registrations', (table: Knex.CreateTableBuilder) => { + table.increments('id').primary(); + table.string('public_id', 36).notNullable().unique(); + table.integer('user_id').notNullable().references('id').inTable('users').onDelete('CASCADE'); + table.integer('campaign_id').notNullable().references('id').inTable('campaigns').onDelete('CASCADE'); + table.boolean('notification_sent').defaultTo(false); + }); } export async function down(knex: Knex): Promise { + return knex.schema.dropTable('registrations'); } From 6bf689aa1d8e61e237f8bf127b519afb66d1cf97 Mon Sep 17 00:00:00 2001 From: Rafael do Amaral Costa <104049906+jake7038@users.noreply.github.com> Date: Sun, 20 Sep 2026 18:05:17 -0300 Subject: [PATCH 3/5] Change public_id column type to UUID --- back/src/database/migrations/20260912221551_campanhas.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/src/database/migrations/20260912221551_campanhas.ts b/back/src/database/migrations/20260912221551_campanhas.ts index 8dec5a6..c227950 100644 --- a/back/src/database/migrations/20260912221551_campanhas.ts +++ b/back/src/database/migrations/20260912221551_campanhas.ts @@ -4,7 +4,7 @@ export async function up(knex: Knex): Promise { return knex.schema.createTable("campaigns", (table: Knex.CreateTableBuilder) => { table.increments("id").primary(); - table.string("public_id", 36).notNullable().unique(); + table.uuid("public_id").notNullable().unique(); table.string("title", 255).notNullable(); table.text("description").nullable(); table.string("pix_key", 255).notNullable(); @@ -25,4 +25,4 @@ export async function down(knex: Knex): Promise { return knex.schema.dropTableIfExists("campaigns"); -} \ No newline at end of file +} From 53b6fa16323f76b5817de8142ec010b702fbf9ec Mon Sep 17 00:00:00 2001 From: Rafael do Amaral Costa <104049906+jake7038@users.noreply.github.com> Date: Sun, 20 Sep 2026 18:05:51 -0300 Subject: [PATCH 4/5] Remove public_id column from social_networks table --- back/src/database/migrations/20260912221823_redes_sociais.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/back/src/database/migrations/20260912221823_redes_sociais.ts b/back/src/database/migrations/20260912221823_redes_sociais.ts index b095863..8e12bdf 100644 --- a/back/src/database/migrations/20260912221823_redes_sociais.ts +++ b/back/src/database/migrations/20260912221823_redes_sociais.ts @@ -4,7 +4,6 @@ import type { Knex } from "knex"; export async function up(knex: Knex): Promise { return knex.schema.createTable('social_networks', (table: Knex.CreateTableBuilder) => { table.increments('id').primary(); - table.string('public_id', 36).notNullable().unique(); table.integer('user_id').notNullable().references('id').inTable('users').onDelete('CASCADE'); table.enum('platform', ['instagram', 'facebook', 'tiktok', 'youtube', 'x', 'other']).notNullable(); table.text('url').notNullable(); From 2414811941dd8fd85467d29fc80b5e297c37b6c2 Mon Sep 17 00:00:00 2001 From: Rafael do Amaral Costa <104049906+jake7038@users.noreply.github.com> Date: Sun, 20 Sep 2026 18:06:11 -0300 Subject: [PATCH 5/5] Change public_id column type to UUID --- back/src/database/migrations/20260912221841_inscricao.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/database/migrations/20260912221841_inscricao.ts b/back/src/database/migrations/20260912221841_inscricao.ts index 8aef8e4..5853b21 100644 --- a/back/src/database/migrations/20260912221841_inscricao.ts +++ b/back/src/database/migrations/20260912221841_inscricao.ts @@ -4,7 +4,7 @@ import type { Knex } from "knex"; export async function up(knex: Knex): Promise { return knex.schema.createTable('registrations', (table: Knex.CreateTableBuilder) => { table.increments('id').primary(); - table.string('public_id', 36).notNullable().unique(); + table.uuid('public_id').notNullable().unique(); table.integer('user_id').notNullable().references('id').inTable('users').onDelete('CASCADE'); table.integer('campaign_id').notNullable().references('id').inTable('campaigns').onDelete('CASCADE'); table.boolean('notification_sent').defaultTo(false);