drizzle-multitenant 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -2
- package/dist/cli/index.js +9 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/integrations/nestjs/index.d.ts +159 -3
- package/dist/integrations/nestjs/index.js +177 -29
- package/dist/integrations/nestjs/index.js.map +1 -1
- package/package.json +1 -1
- package/roadmap.md +105 -7
package/package.json
CHANGED
package/roadmap.md
CHANGED
|
@@ -42,6 +42,14 @@
|
|
|
42
42
|
- [x] 148 testes passando
|
|
43
43
|
- [x] Licença MIT
|
|
44
44
|
|
|
45
|
+
### v1.0.3 - NestJS DX Improvements
|
|
46
|
+
- [x] `TenantDbFactory` para singleton services (cron jobs, event handlers)
|
|
47
|
+
- [x] `@InjectTenantDbFactory()` decorator
|
|
48
|
+
- [x] Debug utilities para proxies (`__debug`, `__tenantId`, `__isProxy`)
|
|
49
|
+
- [x] `console.log(tenantDb)` mostra informações úteis
|
|
50
|
+
- [x] CLI `migrationsTable` config support
|
|
51
|
+
- [x] 154 testes passando
|
|
52
|
+
|
|
45
53
|
---
|
|
46
54
|
|
|
47
55
|
## Próximas Versões
|
|
@@ -792,13 +800,103 @@ const stats = await adminQuery
|
|
|
792
800
|
|
|
793
801
|
## Quick Wins (Podem entrar em qualquer versão)
|
|
794
802
|
|
|
795
|
-
| Feature | Esforço | Versão |
|
|
796
|
-
|
|
797
|
-
| Health check API | 2h | v1.1.0 |
|
|
798
|
-
| Schema name sanitization | 1h | v1.2.0 |
|
|
799
|
-
| CLI interativo básico | 4h | v1.5.0 |
|
|
800
|
-
| Structured logging hook | 2h | v1.1.0 |
|
|
801
|
-
| Tenant clone (schema only) | 4h | v1.5.0 |
|
|
803
|
+
| Feature | Esforço | Versão | Status |
|
|
804
|
+
|---------|---------|--------|--------|
|
|
805
|
+
| Health check API | 2h | v1.1.0 | Pendente |
|
|
806
|
+
| Schema name sanitization | 1h | v1.2.0 | Pendente |
|
|
807
|
+
| CLI interativo básico | 4h | v1.5.0 | Pendente |
|
|
808
|
+
| Structured logging hook | 2h | v1.1.0 | Pendente |
|
|
809
|
+
| Tenant clone (schema only) | 4h | v1.5.0 | Pendente |
|
|
810
|
+
| ~~CLI migrationsTable config~~ | 1h | v1.0.3 | **Concluído** |
|
|
811
|
+
| ~~TenantDbFactory para singletons~~ | 2h | v1.0.3 | **Concluído** |
|
|
812
|
+
| ~~Debug utilities para proxies~~ | 1h | v1.0.3 | **Concluído** |
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
## v1.0.4 - CLI migrationsTable Support
|
|
817
|
+
|
|
818
|
+
### Problema
|
|
819
|
+
|
|
820
|
+
A CLI do `drizzle-multitenant` usa a tabela `__drizzle_migrations` para tracking de migrations, mas não permite configurar um nome diferente. Isso causa incompatibilidade com projetos que já usam outra tabela de tracking (ex: `__drizzle_tenant_migrations`).
|
|
821
|
+
|
|
822
|
+
### Solução
|
|
823
|
+
|
|
824
|
+
Ler o campo `migrationsTable` do objeto `migrations` na config e passá-lo para o `Migrator`.
|
|
825
|
+
|
|
826
|
+
### Mudanças Necessárias
|
|
827
|
+
|
|
828
|
+
#### 1. Atualizar `loadConfig` em `src/cli/utils.ts`
|
|
829
|
+
|
|
830
|
+
```typescript
|
|
831
|
+
export async function loadConfig(configPath?: string) {
|
|
832
|
+
// ... código existente ...
|
|
833
|
+
|
|
834
|
+
return {
|
|
835
|
+
config: exported,
|
|
836
|
+
migrationsFolder: exported.migrations?.tenantFolder,
|
|
837
|
+
tenantDiscovery: exported.migrations?.tenantDiscovery,
|
|
838
|
+
migrationsTable: exported.migrations?.migrationsTable, // NOVO
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
#### 2. Atualizar comandos em `src/cli/commands/`
|
|
844
|
+
|
|
845
|
+
Passar `migrationsTable` para o `createMigrator`:
|
|
846
|
+
|
|
847
|
+
```typescript
|
|
848
|
+
// migrate.ts, status.ts, tenant-create.ts, tenant-drop.ts
|
|
849
|
+
const { config, migrationsFolder, tenantDiscovery, migrationsTable } = await loadConfig(options.config);
|
|
850
|
+
|
|
851
|
+
const migrator = createMigrator(config, {
|
|
852
|
+
migrationsFolder: folder,
|
|
853
|
+
tenantDiscovery: discoveryFn,
|
|
854
|
+
migrationsTable, // NOVO - passa undefined se não configurado (usa default)
|
|
855
|
+
});
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
#### 3. Atualizar tipos
|
|
859
|
+
|
|
860
|
+
```typescript
|
|
861
|
+
// types.ts ou onde apropriado
|
|
862
|
+
interface MigrationsConfig {
|
|
863
|
+
tenantFolder: string;
|
|
864
|
+
tenantDiscovery: () => Promise<string[]>;
|
|
865
|
+
migrationsTable?: string; // NOVO
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
### Exemplo de Uso
|
|
870
|
+
|
|
871
|
+
```typescript
|
|
872
|
+
// tenant.config.ts
|
|
873
|
+
export default {
|
|
874
|
+
...config,
|
|
875
|
+
migrations: {
|
|
876
|
+
tenantFolder: "./drizzle/tenant",
|
|
877
|
+
tenantDiscovery: discoverTenants,
|
|
878
|
+
migrationsTable: "__drizzle_tenant_migrations", // NOVO - usa tabela customizada
|
|
879
|
+
},
|
|
880
|
+
};
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### Compatibilidade
|
|
884
|
+
|
|
885
|
+
- **Backward compatible**: Se não configurado, usa `__drizzle_migrations` (comportamento atual)
|
|
886
|
+
- **Migration path**: Projetos existentes podem:
|
|
887
|
+
1. Configurar a tabela antiga na config
|
|
888
|
+
2. Ou renomear a tabela no banco para o novo padrão
|
|
889
|
+
|
|
890
|
+
### Checklist
|
|
891
|
+
|
|
892
|
+
- [x] Atualizar `loadConfig` para extrair `migrationsTable`
|
|
893
|
+
- [x] Atualizar `migrate` command
|
|
894
|
+
- [x] Atualizar `status` command
|
|
895
|
+
- [x] Atualizar `tenant:create` command
|
|
896
|
+
- [x] Atualizar `tenant:drop` command
|
|
897
|
+
- [x] Adicionar teste unitário
|
|
898
|
+
- [x] Atualizar README com exemplo
|
|
899
|
+
- [x] ~~Publicar v1.0.4~~ (incluído em v1.0.3)
|
|
802
900
|
|
|
803
901
|
---
|
|
804
902
|
|