Skip to content
Merged
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
10 changes: 9 additions & 1 deletion back/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
PORT=
HOST=
NODE_ENV=

NODE_ENV=

DB_HOST=
DB_PORT=
DB_USER=
DB_PASSWORD=
DB_NAME=
DATABASE_URL=
44 changes: 44 additions & 0 deletions back/knexfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Knex } from "knex";
import "dotenv/config";

function requireEnv(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`Variável de ambiente obrigatória ausente: ${name}`);
}
return value;
}

const config: Record<string, Knex.Config> = {
development: {
client: "pg",
connection: {
host: String(process.env.DB_HOST ),
port: Number(process.env.DB_PORT),
user: requireEnv("DB_USER"),
password: requireEnv("DB_PASSWORD"),
database: requireEnv("DB_NAME"),
},
migrations: {
directory: "./src/database/migrations",
extension: "ts",
},
seeds: {
directory: "./src/database/seeds",
extension: "ts",
},
pool: { min: 2, max: 10 },
},

production: {
client: "pg",
connection: requireEnv("DATABASE_URL"),
migrations: {
directory: "./src/database/migrations",
extension: "ts",
},
pool: { min: 2, max: 10 },
},
};

export default config;
7 changes: 6 additions & 1 deletion back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "tsx watch src/server.ts"
"dev": "tsx watch src/server.ts",
"migrate:make": "tsx node_modules/knex/bin/cli.js migrate:make --knexfile knexfile.ts",
"migrate:latest": "tsx node_modules/knex/bin/cli.js migrate:latest --knexfile knexfile.ts",
"migrate:rollback": "tsx node_modules/knex/bin/cli.js migrate:rollback --knexfile knexfile.ts",
"seed:make": "tsx node_modules/knex/bin/cli.js seed:make --knexfile knexfile.ts",
"seed:run": "tsx node_modules/knex/bin/cli.js seed:run --knexfile knexfile.ts"
},
"type": "module",
"keywords": [],
Expand Down
12 changes: 12 additions & 0 deletions back/src/database/migrations/20260911201457_user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {

}


export async function down(knex: Knex): Promise<void> {

}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221551_campanhas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221614_vaquinhas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221623_rifas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221823_redes_sociais.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221836_comprovantes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

10 changes: 10 additions & 0 deletions back/src/database/migrations/20260912221841_inscricao.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Knex } from "knex";


export async function up(knex: Knex): Promise<void> {
}


export async function down(knex: Knex): Promise<void> {
}

Loading