@tamyla/clodo-framework 3.0.2 → 3.0.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.0.3](https://github.com/tamylaa/clodo-framework/compare/v3.0.2...v3.0.3) (2025-10-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * resolve database creation redundancy in deployments ([4a54f2c](https://github.com/tamylaa/clodo-framework/commit/4a54f2ce4bd1bb17d49c4d911171a01179fbd519))
7
+
1
8
  ## [3.0.2](https://github.com/tamylaa/clodo-framework/compare/v3.0.1...v3.0.2) (2025-10-14)
2
9
 
3
10
 
@@ -17,7 +17,7 @@ import { ConfigurationValidator } from '../security/ConfigurationValidator.js';
17
17
  import { exec } from 'child_process';
18
18
  import { promisify } from 'util';
19
19
  import { join } from 'path';
20
- import { createDatabase } from '../utils/cloudflare/index.js';
20
+ import { createDatabase, databaseExists, getDatabaseId } from '../utils/cloudflare/index.js';
21
21
  const execAsync = promisify(exec);
22
22
 
23
23
  /**
@@ -267,10 +267,23 @@ export class MultiDomainOrchestrator {
267
267
  try {
268
268
  // Create D1 database using Cloudflare ops
269
269
  const databaseName = `${domain.replace(/\./g, '-')}-${this.environment}-db`;
270
- console.log(` 📦 Creating database: ${databaseName}`);
271
- const databaseId = await createDatabase(databaseName);
272
- console.log(` Database created: ${databaseName}`);
273
- console.log(` 📊 Database ID: ${databaseId}`);
270
+
271
+ // Check if database already exists
272
+ console.log(` Checking if database exists: ${databaseName}`);
273
+ const exists = await databaseExists(databaseName);
274
+ let databaseId;
275
+ let created = false;
276
+ if (exists) {
277
+ console.log(` ✅ Database already exists: ${databaseName}`);
278
+ databaseId = await getDatabaseId(databaseName);
279
+ console.log(` 📊 Existing Database ID: ${databaseId}`);
280
+ } else {
281
+ console.log(` 📦 Creating database: ${databaseName}`);
282
+ databaseId = await createDatabase(databaseName);
283
+ console.log(` ✅ Database created: ${databaseName}`);
284
+ console.log(` 📊 Database ID: ${databaseId}`);
285
+ created = true;
286
+ }
274
287
 
275
288
  // Store database info in domain state
276
289
  const domainState = this.portfolioState.domainStates.get(domain);
@@ -313,17 +326,18 @@ export class MultiDomainOrchestrator {
313
326
  }
314
327
 
315
328
  // Log comprehensive audit event
316
- this.stateManager.logAuditEvent('DATABASE_CREATED', domain, {
329
+ this.stateManager.logAuditEvent(created ? 'DATABASE_CREATED' : 'DATABASE_FOUND', domain, {
317
330
  databaseName,
318
331
  databaseId,
319
332
  environment: this.environment,
320
333
  migrationsApplied: true,
321
- isRemote: this.environment !== 'development'
334
+ isRemote: this.environment !== 'development',
335
+ created
322
336
  });
323
337
  return {
324
338
  databaseName,
325
339
  databaseId,
326
- created: true,
340
+ created,
327
341
  migrationsApplied: true
328
342
  };
329
343
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamyla/clodo-framework",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Reusable framework for Clodo-style software architecture on Cloudflare Workers + D1",
5
5
  "type": "module",
6
6
  "sideEffects": [