feat(db): renomear tabelas de inglês para português

- user_preferences → preferencias_usuario
- pagador_shares → compartilhamentos_pagador
- saved_insights → insights_salvos
- api_tokens → tokens_api
- inbox_items → pre_lancamentos
- installment_anticipations → antecipacoes_parcelas

Mantidas as tabelas do Better-Auth em inglês (user, account, session, verification)
This commit is contained in:
Felipe Coutinho
2026-01-27 14:19:29 +00:00
parent a7f63fb77a
commit d63963d190
4 changed files with 2458 additions and 89 deletions

View File

@@ -0,0 +1,31 @@
-- Migration: Rename English table names to Portuguese
-- This migration renames tables to maintain consistency with the codebase
-- Rename tables
ALTER TABLE "user_preferences" RENAME TO "preferencias_usuario";
ALTER TABLE "pagador_shares" RENAME TO "compartilhamentos_pagador";
ALTER TABLE "saved_insights" RENAME TO "insights_salvos";
ALTER TABLE "api_tokens" RENAME TO "tokens_api";
ALTER TABLE "inbox_items" RENAME TO "pre_lancamentos";
ALTER TABLE "installment_anticipations" RENAME TO "antecipacoes_parcelas";
-- Rename indexes for preferencias_usuario (was user_preferences)
-- The unique constraint index name is auto-generated, keeping it as is since Drizzle handles it
-- Rename indexes for compartilhamentos_pagador (was pagador_shares)
ALTER INDEX IF EXISTS "pagador_shares_unique" RENAME TO "compartilhamentos_pagador_unique";
-- Rename indexes for insights_salvos (was saved_insights)
ALTER INDEX IF EXISTS "saved_insights_user_period_idx" RENAME TO "insights_salvos_user_period_idx";
-- Rename indexes for tokens_api (was api_tokens)
ALTER INDEX IF EXISTS "api_tokens_user_id_idx" RENAME TO "tokens_api_user_id_idx";
ALTER INDEX IF EXISTS "api_tokens_token_hash_idx" RENAME TO "tokens_api_token_hash_idx";
-- Rename indexes for pre_lancamentos (was inbox_items)
ALTER INDEX IF EXISTS "inbox_items_user_id_status_idx" RENAME TO "pre_lancamentos_user_id_status_idx";
ALTER INDEX IF EXISTS "inbox_items_user_id_created_at_idx" RENAME TO "pre_lancamentos_user_id_created_at_idx";
-- Rename indexes for antecipacoes_parcelas (was installment_anticipations)
ALTER INDEX IF EXISTS "installment_anticipations_series_id_idx" RENAME TO "antecipacoes_parcelas_series_id_idx";
ALTER INDEX IF EXISTS "installment_anticipations_user_id_idx" RENAME TO "antecipacoes_parcelas_user_id_idx";

View File

@@ -0,0 +1,63 @@
ALTER TABLE "installment_anticipations" RENAME TO "antecipacoes_parcelas";--> statement-breakpoint
ALTER TABLE "pagador_shares" RENAME TO "compartilhamentos_pagador";--> statement-breakpoint
ALTER TABLE "saved_insights" RENAME TO "insights_salvos";--> statement-breakpoint
ALTER TABLE "inbox_items" RENAME TO "pre_lancamentos";--> statement-breakpoint
ALTER TABLE "user_preferences" RENAME TO "preferencias_usuario";--> statement-breakpoint
ALTER TABLE "api_tokens" RENAME TO "tokens_api";--> statement-breakpoint
ALTER TABLE "preferencias_usuario" DROP CONSTRAINT "user_preferences_user_id_unique";--> statement-breakpoint
ALTER TABLE "tokens_api" DROP CONSTRAINT "api_tokens_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "pre_lancamentos" DROP CONSTRAINT "inbox_items_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "pre_lancamentos" DROP CONSTRAINT "inbox_items_lancamento_id_lancamentos_id_fk";
--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" DROP CONSTRAINT "installment_anticipations_lancamento_id_lancamentos_id_fk";
--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" DROP CONSTRAINT "installment_anticipations_pagador_id_pagadores_id_fk";
--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" DROP CONSTRAINT "installment_anticipations_categoria_id_categorias_id_fk";
--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" DROP CONSTRAINT "installment_anticipations_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "lancamentos" DROP CONSTRAINT "lancamentos_antecipacao_id_installment_anticipations_id_fk";
--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" DROP CONSTRAINT "pagador_shares_pagador_id_pagadores_id_fk";
--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" DROP CONSTRAINT "pagador_shares_shared_with_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" DROP CONSTRAINT "pagador_shares_created_by_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "insights_salvos" DROP CONSTRAINT "saved_insights_user_id_user_id_fk";
--> statement-breakpoint
ALTER TABLE "preferencias_usuario" DROP CONSTRAINT "user_preferences_user_id_user_id_fk";
--> statement-breakpoint
DROP INDEX "api_tokens_user_id_idx";--> statement-breakpoint
DROP INDEX "api_tokens_token_hash_idx";--> statement-breakpoint
DROP INDEX "inbox_items_user_id_status_idx";--> statement-breakpoint
DROP INDEX "inbox_items_user_id_created_at_idx";--> statement-breakpoint
DROP INDEX "installment_anticipations_series_id_idx";--> statement-breakpoint
DROP INDEX "installment_anticipations_user_id_idx";--> statement-breakpoint
DROP INDEX "pagador_shares_unique";--> statement-breakpoint
DROP INDEX "saved_insights_user_period_idx";--> statement-breakpoint
ALTER TABLE "tokens_api" ADD CONSTRAINT "tokens_api_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "pre_lancamentos" ADD CONSTRAINT "pre_lancamentos_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "pre_lancamentos" ADD CONSTRAINT "pre_lancamentos_lancamento_id_lancamentos_id_fk" FOREIGN KEY ("lancamento_id") REFERENCES "public"."lancamentos"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" ADD CONSTRAINT "antecipacoes_parcelas_lancamento_id_lancamentos_id_fk" FOREIGN KEY ("lancamento_id") REFERENCES "public"."lancamentos"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" ADD CONSTRAINT "antecipacoes_parcelas_pagador_id_pagadores_id_fk" FOREIGN KEY ("pagador_id") REFERENCES "public"."pagadores"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" ADD CONSTRAINT "antecipacoes_parcelas_categoria_id_categorias_id_fk" FOREIGN KEY ("categoria_id") REFERENCES "public"."categorias"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "antecipacoes_parcelas" ADD CONSTRAINT "antecipacoes_parcelas_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "lancamentos" ADD CONSTRAINT "lancamentos_antecipacao_id_antecipacoes_parcelas_id_fk" FOREIGN KEY ("antecipacao_id") REFERENCES "public"."antecipacoes_parcelas"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" ADD CONSTRAINT "compartilhamentos_pagador_pagador_id_pagadores_id_fk" FOREIGN KEY ("pagador_id") REFERENCES "public"."pagadores"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" ADD CONSTRAINT "compartilhamentos_pagador_shared_with_user_id_user_id_fk" FOREIGN KEY ("shared_with_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "compartilhamentos_pagador" ADD CONSTRAINT "compartilhamentos_pagador_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "insights_salvos" ADD CONSTRAINT "insights_salvos_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "preferencias_usuario" ADD CONSTRAINT "preferencias_usuario_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "tokens_api_user_id_idx" ON "tokens_api" USING btree ("user_id");--> statement-breakpoint
CREATE UNIQUE INDEX "tokens_api_token_hash_idx" ON "tokens_api" USING btree ("token_hash");--> statement-breakpoint
CREATE INDEX "pre_lancamentos_user_id_status_idx" ON "pre_lancamentos" USING btree ("user_id","status");--> statement-breakpoint
CREATE INDEX "pre_lancamentos_user_id_created_at_idx" ON "pre_lancamentos" USING btree ("user_id","created_at");--> statement-breakpoint
CREATE INDEX "antecipacoes_parcelas_series_id_idx" ON "antecipacoes_parcelas" USING btree ("series_id");--> statement-breakpoint
CREATE INDEX "antecipacoes_parcelas_user_id_idx" ON "antecipacoes_parcelas" USING btree ("user_id");--> statement-breakpoint
CREATE UNIQUE INDEX "compartilhamentos_pagador_unique" ON "compartilhamentos_pagador" USING btree ("pagador_id","shared_with_user_id");--> statement-breakpoint
CREATE UNIQUE INDEX "insights_salvos_user_period_idx" ON "insights_salvos" USING btree ("user_id","period");--> statement-breakpoint
ALTER TABLE "preferencias_usuario" ADD CONSTRAINT "preferencias_usuario_user_id_unique" UNIQUE("user_id");

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +1,104 @@
{ {
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",
"entries": [ "entries": [
{ {
"idx": 0, "idx": 0,
"version": "7", "version": "7",
"when": 1762993507299, "when": 1762993507299,
"tag": "0000_flashy_manta", "tag": "0000_flashy_manta",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 1, "idx": 1,
"version": "7", "version": "7",
"when": 1765199006435, "when": 1765199006435,
"tag": "0001_young_mister_fear", "tag": "0001_young_mister_fear",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 2, "idx": 2,
"version": "7", "version": "7",
"when": 1765200545692, "when": 1765200545692,
"tag": "0002_slimy_flatman", "tag": "0002_slimy_flatman",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 3, "idx": 3,
"version": "7", "version": "7",
"when": 1767102605526, "when": 1767102605526,
"tag": "0003_green_korg", "tag": "0003_green_korg",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 4, "idx": 4,
"version": "7", "version": "7",
"when": 1767104066872, "when": 1767104066872,
"tag": "0004_acoustic_mach_iv", "tag": "0004_acoustic_mach_iv",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 5, "idx": 5,
"version": "7", "version": "7",
"when": 1767106121811, "when": 1767106121811,
"tag": "0005_adorable_bruce_banner", "tag": "0005_adorable_bruce_banner",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 6, "idx": 6,
"version": "7", "version": "7",
"when": 1767107487318, "when": 1767107487318,
"tag": "0006_youthful_mister_fear", "tag": "0006_youthful_mister_fear",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 7, "idx": 7,
"version": "7", "version": "7",
"when": 1767118780033, "when": 1767118780033,
"tag": "0007_sturdy_kate_bishop", "tag": "0007_sturdy_kate_bishop",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 8, "idx": 8,
"version": "7", "version": "7",
"when": 1767125796314, "when": 1767125796314,
"tag": "0008_fat_stick", "tag": "0008_fat_stick",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 9, "idx": 9,
"version": "7", "version": "7",
"when": 1768925100873, "when": 1768925100873,
"tag": "0009_add_dashboard_widgets", "tag": "0009_add_dashboard_widgets",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 10, "idx": 10,
"version": "7", "version": "7",
"when": 1769369834242, "when": 1769369834242,
"tag": "0010_lame_psynapse", "tag": "0010_lame_psynapse",
"breakpoints": true "breakpoints": true
}, },
{ {
"idx": 11, "idx": 11,
"version": "7", "version": "7",
"when": 1769447087678, "when": 1769447087678,
"tag": "0011_remove_unused_inbox_columns", "tag": "0011_remove_unused_inbox_columns",
"breakpoints": true "breakpoints": true
} },
] {
} "idx": 12,
"version": "7",
"when": 1769533200000,
"tag": "0012_rename_tables_to_portuguese",
"breakpoints": true
},
{
"idx": 13,
"version": "7",
"when": 1769523352777,
"tag": "0013_fancy_rick_jones",
"breakpoints": true
}
]
}