drizzle-multitenant 1.3.2 → 1.3.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/dist/cli/index.js CHANGED
@@ -1745,11 +1745,11 @@ complete -c drizzle-multitenant -n "__fish_seen_subcommand_from completion" -a "
1745
1745
  Shared schema is already up to date.
1746
1746
  `)),await this.renderer.pressEnterToContinue();return}console.log(M.cyan(`
1747
1747
  Pending shared migrations: ${this.sharedStatus.pendingCount}
1748
- `));for(let t of this.sharedStatus.pendingMigrations)console.log(M.dim(` - ${t}`));console.log("");let e=st("Migrating shared schema...").start();try{let r=await I(this.ctx.config,{migrationsFolder:this.ctx.migrationsFolder,sharedMigrationsFolder:this.ctx.sharedMigrationsFolder,...this.ctx.migrationsTable&&{migrationsTable:this.ctx.migrationsTable},tenantDiscovery:this.ctx.tenantDiscovery}).migrateShared({onProgress:(a,o)=>{a==="migrating"&&o&&(e.text=`Applying: ${o}`);}});if(r.success){e.succeed(`Applied ${r.appliedMigrations.length} migration(s)`),console.log("");for(let a of r.appliedMigrations)console.log(M.green(` \u2713 ${a}`));}else e.fail("Migration failed"),console.log(M.red(`
1748
+ `));for(let t of this.sharedStatus.pendingMigrations)console.log(M.dim(` - ${t}`));console.log("");let e=st("Migrating shared schema...").start();try{let r=await I(this.ctx.config,{migrationsFolder:this.ctx.migrationsFolder,sharedMigrationsFolder:this.ctx.sharedMigrationsFolder,...this.ctx.migrationsTable&&{migrationsTable:this.ctx.migrationsTable},...this.ctx.sharedMigrationsTable&&{sharedMigrationsTable:this.ctx.sharedMigrationsTable},...this.ctx.sharedTableFormat&&this.ctx.sharedTableFormat!=="auto"&&{sharedTableFormat:this.ctx.sharedTableFormat},...this.ctx.sharedDefaultFormat&&{sharedDefaultFormat:this.ctx.sharedDefaultFormat},tenantDiscovery:this.ctx.tenantDiscovery}).migrateShared({onProgress:(a,o)=>{a==="migrating"&&o&&(e.text=`Applying: ${o}`);}});if(r.success){e.succeed(`Applied ${r.appliedMigrations.length} migration(s)`),console.log("");for(let a of r.appliedMigrations)console.log(M.green(` \u2713 ${a}`));}else e.fail("Migration failed"),console.log(M.red(`
1749
1749
  Error: ${r.error}`));}catch(t){e.fail("Migration failed"),console.log(M.red(`
1750
- ${t.message}`));}console.log(""),await this.renderer.pressEnterToContinue();}async handleScreenAction(e){if(!this.ctx)return {type:"exit"};if(e.type==="navigate")switch(e.screen){case "migrate":{let r=await new ge(this.ctx,this.renderer).show(this.statuses);return this.handleScreenAction(r)}case "migrate-single":{let t=e.params?.tenantId;if(t){let a=await new ge(this.ctx,this.renderer).migrateSingle(t);return await this.refreshStatuses(),a}return {type:"back"}}default:return {type:"back"}}return e.type==="refresh"&&await this.refreshStatuses(),e}async loadMenuContext(){let e=st("Loading configuration...").start();try{let{config:t,migrationsFolder:r,migrationsTable:a,tenantDiscovery:o,sharedMigrationsFolder:s,sharedConfigSource:i,drizzleKitConfigFile:c}=await k(this.configPath);if(!o)return e.fail("No tenant discovery function found in config"),console.log(M.dim(`
1751
- Add migrations.tenantDiscovery to your config:`)),console.log(M.dim(" migrations: {")),console.log(M.dim(" tenantDiscovery: async () => ['tenant-1', 'tenant-2'],")),console.log(M.dim(" }")),null;let l=O(r),m;if(s)try{m=O(s),this.hasSharedMigrations=!0;}catch{this.hasSharedMigrations=!1;}return e.succeed("Configuration loaded"),m&&i?console.log(M.dim(` \u2514\u2500 Shared schema: ${s} ${M.cyan(`(from ${i})`)}`)):c&&!s&&console.log(M.dim(` \u2514\u2500 Found ${c} (no shared migrations folder configured)`)),{config:t,migrationsFolder:l,migrationsTable:a,tenantDiscovery:o,sharedMigrationsFolder:m,sharedConfigSource:i??void 0,drizzleKitConfigFile:c??void 0}}catch(t){return e.fail("Failed to load configuration"),console.log(M.red(`
1752
- ${t.message}`)),null}}async refreshStatuses(){if(!this.ctx)return;let e=st("Fetching status...").start();try{let t=I(this.ctx.config,{migrationsFolder:this.ctx.migrationsFolder,sharedMigrationsFolder:this.ctx.sharedMigrationsFolder,...this.ctx.migrationsTable&&{migrationsTable:this.ctx.migrationsTable},tenantDiscovery:this.ctx.tenantDiscovery});this.statuses=await t.getStatus(),this.hasSharedMigrations&&(this.sharedStatus=await t.getSharedStatus()),e.stop();}catch(t){e.fail("Failed to fetch status"),console.log(M.red(`
1750
+ ${t.message}`));}console.log(""),await this.renderer.pressEnterToContinue();}async handleScreenAction(e){if(!this.ctx)return {type:"exit"};if(e.type==="navigate")switch(e.screen){case "migrate":{let r=await new ge(this.ctx,this.renderer).show(this.statuses);return this.handleScreenAction(r)}case "migrate-single":{let t=e.params?.tenantId;if(t){let a=await new ge(this.ctx,this.renderer).migrateSingle(t);return await this.refreshStatuses(),a}return {type:"back"}}default:return {type:"back"}}return e.type==="refresh"&&await this.refreshStatuses(),e}async loadMenuContext(){let e=st("Loading configuration...").start();try{let{config:t,migrationsFolder:r,migrationsTable:a,tenantDiscovery:o,sharedMigrationsFolder:s,sharedMigrationsTable:i,sharedTableFormat:c,sharedDefaultFormat:l,sharedConfigSource:m,drizzleKitConfigFile:u}=await k(this.configPath);if(!o)return e.fail("No tenant discovery function found in config"),console.log(M.dim(`
1751
+ Add migrations.tenantDiscovery to your config:`)),console.log(M.dim(" migrations: {")),console.log(M.dim(" tenantDiscovery: async () => ['tenant-1', 'tenant-2'],")),console.log(M.dim(" }")),null;let p=O(r),h;if(s)try{h=O(s),this.hasSharedMigrations=!0;}catch{this.hasSharedMigrations=!1;}return e.succeed("Configuration loaded"),h&&m?console.log(M.dim(` \u2514\u2500 Shared schema: ${s} ${M.cyan(`(from ${m})`)}`)):u&&!s&&console.log(M.dim(` \u2514\u2500 Found ${u} (no shared migrations folder configured)`)),{config:t,migrationsFolder:p,migrationsTable:a,tenantDiscovery:o,sharedMigrationsFolder:h,sharedMigrationsTable:i,sharedTableFormat:c,sharedDefaultFormat:l,sharedConfigSource:m??void 0,drizzleKitConfigFile:u??void 0}}catch(t){return e.fail("Failed to load configuration"),console.log(M.red(`
1752
+ ${t.message}`)),null}}async refreshStatuses(){if(!this.ctx)return;let e=st("Fetching status...").start();try{let t=I(this.ctx.config,{migrationsFolder:this.ctx.migrationsFolder,sharedMigrationsFolder:this.ctx.sharedMigrationsFolder,...this.ctx.migrationsTable&&{migrationsTable:this.ctx.migrationsTable},...this.ctx.sharedMigrationsTable&&{sharedMigrationsTable:this.ctx.sharedMigrationsTable},...this.ctx.sharedTableFormat&&this.ctx.sharedTableFormat!=="auto"&&{sharedTableFormat:this.ctx.sharedTableFormat},...this.ctx.sharedDefaultFormat&&{sharedDefaultFormat:this.ctx.sharedDefaultFormat},tenantDiscovery:this.ctx.tenantDiscovery});this.statuses=await t.getStatus(),this.hasSharedMigrations&&(this.sharedStatus=await t.getSharedStatus()),e.stop();}catch(t){e.fail("Failed to fetch status"),console.log(M.red(`
1753
1753
  ${t.message}`)),this.statuses=[],this.sharedStatus=null;}}};async function pt(n){await new un(n).start();}process.on("SIGINT",()=>{console.log(M.cyan(`
1754
1754
 
1755
1755
  Goodbye!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-multitenant",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "Multi-tenancy toolkit for Drizzle ORM with schema isolation, tenant context, and parallel migrations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",