@zodic/shared 0.0.401 → 0.0.402

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.
Files changed (61) hide show
  1. package/app/api/index.ts +0 -99
  2. package/app/base/AppContext.ts +0 -41
  3. package/app/services/ConceptService.ts +172 -244
  4. package/app/services/PaymentService.ts +61 -2
  5. package/db/migrations/{0000_little_sleeper.sql → 0000_workable_the_hand.sql} +197 -24
  6. package/db/migrations/meta/0000_snapshot.json +1663 -451
  7. package/db/migrations/meta/_journal.json +2 -156
  8. package/db/schema.ts +0 -31
  9. package/drizzle.config.ts +2 -2
  10. package/package.json +10 -5
  11. package/types/scopes/cloudflare.ts +2 -118
  12. package/types/scopes/generic.ts +0 -1
  13. package/utils/buildMessages.ts +1 -32
  14. package/wrangler.toml +24 -3
  15. package/app/durable/ConceptNameDO.ts +0 -199
  16. package/app/durable/index.ts +0 -1
  17. package/app/workflow/old/ArchetypeWorkflow.ts +0 -156
  18. package/db/migrations/0001_mysterious_mystique.sql +0 -47
  19. package/db/migrations/0002_reflective_firelord.sql +0 -13
  20. package/db/migrations/0003_thin_valeria_richards.sql +0 -28
  21. package/db/migrations/0004_loose_iron_monger.sql +0 -15
  22. package/db/migrations/0005_famous_cammi.sql +0 -26
  23. package/db/migrations/0006_fine_manta.sql +0 -1
  24. package/db/migrations/0007_typical_grim_reaper.sql +0 -1
  25. package/db/migrations/0008_fine_betty_brant.sql +0 -1
  26. package/db/migrations/0009_spooky_doctor_spectrum.sql +0 -20
  27. package/db/migrations/0010_tricky_lord_hawal.sql +0 -23
  28. package/db/migrations/0011_hard_king_bedlam.sql +0 -1
  29. package/db/migrations/0012_sudden_doctor_spectrum.sql +0 -27
  30. package/db/migrations/0013_lean_frightful_four.sql +0 -7
  31. package/db/migrations/0014_green_marvel_apes.sql +0 -10
  32. package/db/migrations/0015_zippy_sersi.sql +0 -10
  33. package/db/migrations/0016_awesome_squadron_sinister.sql +0 -1
  34. package/db/migrations/0017_vengeful_electro.sql +0 -1
  35. package/db/migrations/0018_wooden_sersi.sql +0 -16
  36. package/db/migrations/0019_abandoned_orphan.sql +0 -59
  37. package/db/migrations/0020_smiling_blob.sql +0 -1
  38. package/db/migrations/0021_flawless_wallflower.sql +0 -1
  39. package/db/migrations/0022_pale_marvex.sql +0 -1
  40. package/db/migrations/meta/0001_snapshot.json +0 -2200
  41. package/db/migrations/meta/0002_snapshot.json +0 -2284
  42. package/db/migrations/meta/0003_snapshot.json +0 -2417
  43. package/db/migrations/meta/0004_snapshot.json +0 -2417
  44. package/db/migrations/meta/0005_snapshot.json +0 -2417
  45. package/db/migrations/meta/0006_snapshot.json +0 -2425
  46. package/db/migrations/meta/0007_snapshot.json +0 -2433
  47. package/db/migrations/meta/0008_snapshot.json +0 -2425
  48. package/db/migrations/meta/0009_snapshot.json +0 -2425
  49. package/db/migrations/meta/0010_snapshot.json +0 -2594
  50. package/db/migrations/meta/0011_snapshot.json +0 -2602
  51. package/db/migrations/meta/0012_snapshot.json +0 -2602
  52. package/db/migrations/meta/0013_snapshot.json +0 -2649
  53. package/db/migrations/meta/0014_snapshot.json +0 -2723
  54. package/db/migrations/meta/0015_snapshot.json +0 -2711
  55. package/db/migrations/meta/0016_snapshot.json +0 -2715
  56. package/db/migrations/meta/0017_snapshot.json +0 -2723
  57. package/db/migrations/meta/0018_snapshot.json +0 -2834
  58. package/db/migrations/meta/0019_snapshot.json +0 -3244
  59. package/db/migrations/meta/0020_snapshot.json +0 -3252
  60. package/db/migrations/meta/0021_snapshot.json +0 -3254
  61. package/db/migrations/meta/0022_snapshot.json +0 -3260
@@ -1,199 +0,0 @@
1
- import { DurableObjectState } from '@cloudflare/workers-types';
2
-
3
- export class ConceptNameDO {
4
- state: DurableObjectState;
5
- env: any;
6
- names: { 'en-us': string[]; 'pt-br': string[] };
7
- count: number;
8
- timestamps: number[];
9
- lastIndex: number; // ✅ Tracks last processed index
10
-
11
- static TOTAL_NAMES = 1728; // Maximum total names to be generated
12
-
13
- constructor(state: DurableObjectState, env: any) {
14
- this.state = state;
15
- this.env = env;
16
- this.names = { 'en-us': [], 'pt-br': [] };
17
- this.count = 0;
18
- this.timestamps = [];
19
- this.lastIndex = 0; // ✅ Initialize lastIndex
20
- }
21
-
22
- async fetch(request: Request): Promise<Response> {
23
- const url = new URL(request.url);
24
- const method = request.method;
25
-
26
- console.log(`📥 DO Received Request: ${method} ${url.pathname}`);
27
-
28
- if (method === 'GET' && url.pathname === '/names') {
29
- return new Response(JSON.stringify(await this.getNames()), {
30
- headers: { 'Content-Type': 'application/json' },
31
- });
32
- }
33
-
34
- if (method === 'GET' && url.pathname === '/progress') {
35
- return new Response(JSON.stringify(await this.getProgress()), {
36
- headers: { 'Content-Type': 'application/json' },
37
- });
38
- }
39
-
40
- if (method === 'GET' && url.pathname === '/last-index') {
41
- return new Response(JSON.stringify(await this.getLastIndex()), {
42
- headers: { 'Content-Type': 'application/json' },
43
- });
44
- }
45
-
46
- if (method === 'POST' && url.pathname === '/add-name') {
47
- const { language, name, index } = (await request.json()) as {
48
- language: 'en-us' | 'pt-br';
49
- name: string;
50
- index: number;
51
- };
52
-
53
- if (!['en-us', 'pt-br'].includes(language)) {
54
- return new Response('Invalid language', { status: 400 });
55
- }
56
-
57
- await this.addName(language, name, index);
58
- return new Response('OK', { status: 200 });
59
- }
60
-
61
- if (method === 'POST' && url.pathname === '/set-progress') {
62
- const { lastIndex } = (await request.json()) as { lastIndex: number };
63
- await this.setLastIndex(lastIndex);
64
- return new Response('OK', { status: 200 });
65
- }
66
-
67
- return new Response('Not Found', { status: 404 });
68
- }
69
-
70
- async getNames(): Promise<{ 'en-us': string[]; 'pt-br': string[] }> {
71
- if (!this.names['en-us'].length && !this.names['pt-br'].length) {
72
- this.names = (await this.state.storage.get('names')) || {
73
- 'en-us': [],
74
- 'pt-br': [],
75
- };
76
- }
77
- return this.names;
78
- }
79
-
80
- async getProgress(): Promise<{
81
- count: number;
82
- total: number;
83
- lastIndex: number;
84
- progress: string;
85
- ratePerMinute: number;
86
- estimatedTimeMinutes: number | 'N/A';
87
- }> {
88
- console.log(`📡 Fetching progress...`);
89
-
90
- // 🔥 Fetch latest names directly from storage
91
- const storedNames = await this.state.storage.get<{ 'en-us': string[]; 'pt-br': string[] }>('names');
92
- if (storedNames) {
93
- this.names = storedNames;
94
- } else {
95
- this.names = { 'en-us': [], 'pt-br': [] };
96
- }
97
-
98
- await this.loadCount();
99
- await this.loadTimestamps();
100
- await this.loadLastIndex(); // ✅ Ensure latest lastIndex is fetched
101
-
102
- console.log(`🔍 Current stored names (DO): ${JSON.stringify(this.names)}`);
103
-
104
- const now = Date.now();
105
- const oneMinuteAgo = now - 60 * 1000;
106
-
107
- const recentTimestamps = this.timestamps.filter((ts) => ts >= oneMinuteAgo);
108
- const ratePerMinute = recentTimestamps.length;
109
-
110
- // 🔥 Only count the `en-us` names to reflect progress properly
111
- const enUsCount = Array.isArray(this.names['en-us']) ? this.names['en-us'].length : 0;
112
-
113
- console.log(
114
- `🛠️ Debugging Progress: count=${this.count}, en-us=${enUsCount}, lastIndex=${this.lastIndex}`
115
- );
116
-
117
- const remainingNames = ConceptNameDO.TOTAL_NAMES - enUsCount;
118
- const estimatedTimeMinutes =
119
- ratePerMinute > 0 ? Math.round(remainingNames / ratePerMinute) : 'N/A';
120
-
121
- return {
122
- count: this.count, // ✅ Keep full count (en-us + pt-br)
123
- total: ConceptNameDO.TOTAL_NAMES, // ✅ Base progress on 1728
124
- lastIndex: this.lastIndex,
125
- progress: ((enUsCount / ConceptNameDO.TOTAL_NAMES) * 100).toFixed(2) + '%', // ✅ Use only en-us count
126
- ratePerMinute,
127
- estimatedTimeMinutes,
128
- };
129
- }
130
-
131
- async getLastIndex(): Promise<number> {
132
- await this.loadLastIndex(); // ✅ Fetch lastIndex from storage
133
- return this.lastIndex;
134
- }
135
-
136
- async addName(
137
- language: 'en-us' | 'pt-br',
138
- name: string,
139
- index: number
140
- ): Promise<void> {
141
- await this.getNames();
142
- await this.loadCount();
143
- await this.loadLastIndex(); // ✅ Ensure lastIndex is loaded before modifying
144
-
145
- if (!this.names[language].includes(name)) {
146
- this.names[language].push(name);
147
- this.count += 1;
148
-
149
- this.recordTimestamp();
150
-
151
- // 🔥 **Ensure lastIndex is updated**
152
- if (index > this.lastIndex) {
153
- this.lastIndex = index;
154
- }
155
-
156
- // 🔥 **Store all updated values in a single put() call**
157
- await this.state.storage.put({
158
- names: this.names,
159
- count: this.count,
160
- timestamps: this.timestamps,
161
- lastIndex: this.lastIndex, // ✅ Store the last processed index
162
- });
163
-
164
- console.log(
165
- `✅ Added name "${name}" to ${language}, count: ${this.count}, lastIndex: ${this.lastIndex}`
166
- );
167
- }
168
- }
169
-
170
- async setLastIndex(lastIndex: number): Promise<void> {
171
- this.lastIndex = lastIndex;
172
- await this.state.storage.put('lastIndex', this.lastIndex);
173
- console.log(`📌 Updated lastIndex to ${this.lastIndex}`);
174
- }
175
-
176
- async loadCount(): Promise<void> {
177
- this.count = (await this.state.storage.get<number>('count')) || 0;
178
- }
179
-
180
- async loadLastIndex(): Promise<void> {
181
- const storedIndex = await this.state.storage.get<number>('lastIndex');
182
- if (typeof storedIndex === 'number') {
183
- this.lastIndex = storedIndex;
184
- } else {
185
- this.lastIndex = 0; // ✅ Ensure it starts from 0
186
- }
187
- }
188
-
189
- async loadTimestamps(): Promise<void> {
190
- this.timestamps =
191
- (await this.state.storage.get<number[]>('timestamps')) || [];
192
- }
193
-
194
- recordTimestamp(): void {
195
- const now = Date.now();
196
- this.timestamps = this.timestamps.filter((ts) => now - ts < 60 * 60 * 1000);
197
- this.timestamps.push(now);
198
- }
199
- }
@@ -1 +0,0 @@
1
- export * from './ConceptNameDO';
@@ -1,156 +0,0 @@
1
- import { inject, injectable } from 'inversify';
2
- import { Gender } from '../../../types';
3
- import { KVArchetype } from '../../../types/scopes/legacy';
4
- import { AppContext } from '../../base';
5
- import { ArchetypeService } from '../../services/ArchetypeService';
6
- import { LeonardoService } from '../../services/LeonardoService';
7
-
8
- @injectable()
9
- class ArchetypeWorkflow {
10
- constructor(
11
- @inject(AppContext) private context: AppContext,
12
- @inject(ArchetypeService) private archetypeService: ArchetypeService,
13
- @inject(LeonardoService) private leonardoService: LeonardoService
14
- ) {}
15
-
16
- async execute(combinationString: string, gender: Gender) {
17
- const kvKeyBase = `cosmic-mirror:archetypes:${combinationString}:${gender}`;
18
-
19
- console.log('Starting ArchetypeWorkflow for:', {
20
- combinationString,
21
- gender,
22
- });
23
-
24
- const archetypes = await Promise.all(
25
- Array.from({ length: 3 }, (_, i) => i + 1).map(async (index) => {
26
- const kvKey = `${kvKeyBase}:${index}`;
27
- try {
28
- console.log(`Fetching archetype from KV: ${kvKey}`);
29
- return await this.context
30
- .kvCosmicMirrorArchetypesStore()
31
- .get<KVArchetype>(kvKey, 'json');
32
- } catch (error) {
33
- console.error(
34
- `Error fetching archetype KV for index ${index}:`,
35
- error
36
- );
37
- return null;
38
- }
39
- })
40
- ).then((results) => results.filter((result) => result !== null)); // Filter out nulls
41
-
42
- const isGenerating = archetypes.some(
43
- (archetype) => archetype?.status === 'generating'
44
- );
45
-
46
- if (isGenerating) {
47
- console.log(
48
- `Archetype images are already being generated for: ${combinationString}, gender: ${gender}`
49
- );
50
- return { message: 'Images are being processed, please try again later.' };
51
- }
52
-
53
- const missingOrIncomplete =
54
- archetypes.length < 3 ||
55
- archetypes.some((archetype) => archetype?.images.length < 3);
56
-
57
- if (missingOrIncomplete) {
58
- console.log(
59
- `Archetypes missing or incomplete for combination: ${combinationString}, gender: ${gender}. Generating...`
60
- );
61
-
62
- await this.archetypeService.generateBasicInfo(combinationString);
63
-
64
- const updatedArchetypes = await Promise.all(
65
- Array.from({ length: 3 }, (_, i) => i + 1).map(async (index) => {
66
- const kvKey = `${kvKeyBase}:${index}`;
67
- try {
68
- console.log(`Re-fetching archetype from KV: ${kvKey}`);
69
- return await this.context
70
- .kvCosmicMirrorArchetypesStore()
71
- .get<KVArchetype>(kvKey, 'json');
72
- } catch (error) {
73
- console.error(
74
- `Error fetching archetype KV after generation for index ${index}:`,
75
- error
76
- );
77
- return null;
78
- }
79
- })
80
- ).then((results) => results.filter((results) => results != null));
81
-
82
- archetypes.length = 0;
83
- archetypes.push(...updatedArchetypes);
84
- }
85
-
86
- const missingPrompts = archetypes.some(
87
- (archetype) => !archetype?.leonardoPrompt
88
- );
89
-
90
- if (missingPrompts) {
91
- console.log('Generating missing prompts...');
92
- await this.leonardoService.processArchetypesPrompts(combinationString);
93
- }
94
-
95
- const archetypesNeedingImages = archetypes.filter(
96
- (archetype) => archetype?.images.length < 3
97
- );
98
-
99
- if (archetypesNeedingImages.length > 0) {
100
- console.log('Queuing image generation for missing archetypes...');
101
- try {
102
- await Promise.all(
103
- archetypesNeedingImages.map(async (archetype, index) => {
104
- archetype.status = 'generating';
105
- const kvKey = `${kvKeyBase}:${index + 1}`;
106
- await this.context
107
- .kvCosmicMirrorArchetypesStore()
108
- .put(kvKey, JSON.stringify(archetype));
109
- })
110
- );
111
-
112
- await this.leonardoService.queueImagesForArchetypes(
113
- combinationString,
114
- gender
115
- );
116
- } catch (error) {
117
- console.error('Error queuing image generation:', error);
118
-
119
- await Promise.all(
120
- archetypesNeedingImages.map(async (archetype, index) => {
121
- archetype.status = 'idle';
122
- const kvKey = `${kvKeyBase}:${index + 1}`;
123
- await this.context
124
- .kvCosmicMirrorArchetypesStore()
125
- .put(kvKey, JSON.stringify(archetype));
126
- })
127
- );
128
-
129
- throw error;
130
- }
131
-
132
- return { message: 'Images are being processed, please try again later.' };
133
- }
134
-
135
- await Promise.all(
136
- archetypes.map(async (archetype, index) => {
137
- archetype.status = 'idle';
138
- const kvKey = `${kvKeyBase}:${index + 1}`;
139
- await this.context
140
- .kvCosmicMirrorArchetypesStore()
141
- .put(kvKey, JSON.stringify(archetype));
142
- })
143
- );
144
-
145
- console.log('Archetypes fully processed and ready:', archetypes);
146
- return {
147
- archetypes: archetypes.map((arc) => ({
148
- name: arc?.name,
149
- content: arc?.content,
150
- description: arc?.description,
151
- virtues: arc?.virtues,
152
- images: arc?.images,
153
- })),
154
- };
155
- }
156
- }
@@ -1,47 +0,0 @@
1
- CREATE TABLE `aspect_reports` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `aspecting_planet` text NOT NULL,
4
- `aspected_planet` text NOT NULL,
5
- `aspect` text NOT NULL,
6
- `en_description` text,
7
- `pt_description` text,
8
- `en_report` text,
9
- `pt_report` text,
10
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
11
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
12
- );
13
- --> statement-breakpoint
14
- CREATE INDEX `aspect_reports_aspecting_idx` ON `aspect_reports` (`aspecting_planet`);--> statement-breakpoint
15
- CREATE INDEX `aspect_reports_aspected_idx` ON `aspect_reports` (`aspected_planet`);--> statement-breakpoint
16
- CREATE INDEX `aspect_reports_aspect_idx` ON `aspect_reports` (`aspect`);--> statement-breakpoint
17
- CREATE INDEX `aspect_reports_combined_idx` ON `aspect_reports` (`aspecting_planet`,`aspected_planet`,`aspect`);--> statement-breakpoint
18
- CREATE TABLE `astro_reports` (
19
- `id` text PRIMARY KEY NOT NULL,
20
- `type` text NOT NULL,
21
- `name` text NOT NULL,
22
- `sign` text,
23
- `house` integer,
24
- `en_description` text,
25
- `pt_description` text,
26
- `en_report` text,
27
- `pt_report` text,
28
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
29
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
30
- );
31
- --> statement-breakpoint
32
- CREATE INDEX `astro_reports_type_idx` ON `astro_reports` (`type`);--> statement-breakpoint
33
- CREATE INDEX `astro_reports_name_sign_idx` ON `astro_reports` (`name`,`sign`);--> statement-breakpoint
34
- CREATE INDEX `astro_reports_name_house_idx` ON `astro_reports` (`name`,`house`);--> statement-breakpoint
35
- CREATE TABLE `house_reports` (
36
- `id` text PRIMARY KEY NOT NULL,
37
- `sign` text NOT NULL,
38
- `house` integer NOT NULL,
39
- `en_description` text,
40
- `pt_description` text,
41
- `en_report` text,
42
- `pt_report` text,
43
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
44
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
45
- );
46
- --> statement-breakpoint
47
- CREATE INDEX `house_reports_sign_house_idx` ON `house_reports` (`sign`,`house`);
@@ -1,13 +0,0 @@
1
- CREATE TABLE `astro_feature_reports` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `feature_type` text NOT NULL,
4
- `name` text NOT NULL,
5
- `en_description` text,
6
- `pt_description` text,
7
- `en_report` text,
8
- `pt_report` text,
9
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
10
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
11
- );
12
- --> statement-breakpoint
13
- CREATE INDEX `astro_feature_reports_type_name_idx` ON `astro_feature_reports` (`feature_type`,`name`);
@@ -1,28 +0,0 @@
1
- CREATE TABLE `astro_description_templates` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `entity_type` text NOT NULL,
4
- `name` text NOT NULL,
5
- `en_name` text,
6
- `pt_name` text,
7
- `en_description` text NOT NULL,
8
- `pt_description` text NOT NULL,
9
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
10
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
11
- );
12
- --> statement-breakpoint
13
- CREATE INDEX `astro_description_templates_type_name_idx` ON `astro_description_templates` (`entity_type`,`name`);--> statement-breakpoint
14
- ALTER TABLE `aspect_reports` ADD `description_template_id` text REFERENCES astro_description_templates(id);--> statement-breakpoint
15
- CREATE INDEX `aspect_reports_description_template_idx` ON `aspect_reports` (`description_template_id`);--> statement-breakpoint
16
- ALTER TABLE `aspect_reports` DROP COLUMN `en_description`;--> statement-breakpoint
17
- ALTER TABLE `aspect_reports` DROP COLUMN `pt_description`;--> statement-breakpoint
18
- ALTER TABLE `astro_feature_reports` ADD `description_template_id` text REFERENCES astro_description_templates(id);--> statement-breakpoint
19
- CREATE INDEX `astro_feature_reports_description_template_idx` ON `astro_feature_reports` (`description_template_id`);--> statement-breakpoint
20
- ALTER TABLE `astro_feature_reports` DROP COLUMN `en_description`;--> statement-breakpoint
21
- ALTER TABLE `astro_feature_reports` DROP COLUMN `pt_description`;--> statement-breakpoint
22
- ALTER TABLE `astro_reports` ADD `description_template_id` text REFERENCES astro_description_templates(id);--> statement-breakpoint
23
- ALTER TABLE `astro_reports` DROP COLUMN `en_description`;--> statement-breakpoint
24
- ALTER TABLE `astro_reports` DROP COLUMN `pt_description`;--> statement-breakpoint
25
- ALTER TABLE `house_reports` ADD `description_template_id` text REFERENCES astro_description_templates(id);--> statement-breakpoint
26
- CREATE INDEX `house_reports_description_template_idx` ON `house_reports` (`description_template_id`);--> statement-breakpoint
27
- ALTER TABLE `house_reports` DROP COLUMN `en_description`;--> statement-breakpoint
28
- ALTER TABLE `house_reports` DROP COLUMN `pt_description`;
@@ -1,15 +0,0 @@
1
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
- CREATE TABLE `__new_concepts` (
3
- `id` text PRIMARY KEY NOT NULL,
4
- `name` text NOT NULL,
5
- `slug` text NOT NULL,
6
- `planet1` text NOT NULL,
7
- `planet2` text NOT NULL,
8
- `planet3` text NOT NULL
9
- );
10
- --> statement-breakpoint
11
- INSERT INTO `__new_concepts`("id", "name", "slug", "planet1", "planet2", "planet3") SELECT "id", "name", "slug", "planet1", "planet2", "planet3" FROM `concepts`;--> statement-breakpoint
12
- DROP TABLE `concepts`;--> statement-breakpoint
13
- ALTER TABLE `__new_concepts` RENAME TO `concepts`;--> statement-breakpoint
14
- PRAGMA foreign_keys=ON;--> statement-breakpoint
15
- CREATE INDEX `concepts_name_idx` ON `concepts` (`name`);
@@ -1,26 +0,0 @@
1
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
- CREATE TABLE `__new_concepts_data` (
3
- `id` text PRIMARY KEY NOT NULL,
4
- `language` text NOT NULL,
5
- `concept_slug` text NOT NULL,
6
- `combination` text NOT NULL,
7
- `name` text NOT NULL,
8
- `description` text NOT NULL,
9
- `content` text DEFAULT '[]' NOT NULL,
10
- `poem` text DEFAULT '[]' NOT NULL,
11
- `leonardo_prompt` text,
12
- `post_images` text DEFAULT '[]',
13
- `reel_images` text DEFAULT '[]',
14
- `status` text DEFAULT 'idle',
15
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
16
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
17
- );
18
- --> statement-breakpoint
19
- INSERT INTO `__new_concepts_data`("id", "language", "concept_slug", "combination", "name", "description", "content", "poem", "leonardo_prompt", "post_images", "reel_images", "status", "created_at", "updated_at") SELECT "id", "language", "concept_slug", "combination", "name", "description", "content", "poem", "leonardo_prompt", "post_images", "reel_images", "status", "created_at", "updated_at" FROM `concepts_data`;--> statement-breakpoint
20
- DROP TABLE `concepts_data`;--> statement-breakpoint
21
- ALTER TABLE `__new_concepts_data` RENAME TO `concepts_data`;--> statement-breakpoint
22
- PRAGMA foreign_keys=ON;--> statement-breakpoint
23
- CREATE INDEX `concepts_data_language_idx` ON `concepts_data` (`language`);--> statement-breakpoint
24
- CREATE INDEX `concepts_data_concept_slug_idx` ON `concepts_data` (`concept_slug`);--> statement-breakpoint
25
- CREATE INDEX `concepts_data_combination_idx` ON `concepts_data` (`combination`);--> statement-breakpoint
26
- CREATE INDEX `concepts_data_name_idx` ON `concepts_data` (`name`);
@@ -1 +0,0 @@
1
- ALTER TABLE `user_concepts` ADD `image_idx` integer DEFAULT 0;
@@ -1 +0,0 @@
1
- CREATE UNIQUE INDEX `user_concepts_unique_user_concept` ON `user_concepts` (`user_id`,`concept_id`);
@@ -1 +0,0 @@
1
- DROP INDEX `user_concepts_unique_user_concept`;
@@ -1,20 +0,0 @@
1
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
- CREATE TABLE `__new_user_concepts` (
3
- `id` text PRIMARY KEY NOT NULL,
4
- `user_id` text NOT NULL,
5
- `concept_id` text NOT NULL,
6
- `concept_combination_id` text NOT NULL,
7
- `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
8
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
9
- `image_idx` integer DEFAULT 0 NOT NULL,
10
- FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
11
- FOREIGN KEY (`concept_id`) REFERENCES `concepts`(`id`) ON UPDATE no action ON DELETE cascade,
12
- FOREIGN KEY (`concept_combination_id`) REFERENCES `concept_combinations`(`id`) ON UPDATE no action ON DELETE cascade
13
- );
14
- --> statement-breakpoint
15
- INSERT INTO `__new_user_concepts`("id", "user_id", "concept_id", "concept_combination_id", "created_at", "updated_at", "image_idx") SELECT "id", "user_id", "concept_id", "concept_combination_id", "created_at", "updated_at", "image_idx" FROM `user_concepts`;--> statement-breakpoint
16
- DROP TABLE `user_concepts`;--> statement-breakpoint
17
- ALTER TABLE `__new_user_concepts` RENAME TO `user_concepts`;--> statement-breakpoint
18
- PRAGMA foreign_keys=ON;--> statement-breakpoint
19
- CREATE INDEX `user_concepts_user_id_idx` ON `user_concepts` (`user_id`);--> statement-breakpoint
20
- CREATE INDEX `user_concepts_concept_id_idx` ON `user_concepts` (`concept_id`);
@@ -1,23 +0,0 @@
1
- CREATE TABLE `archetypes_data` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `language` text NOT NULL,
4
- `gender` text,
5
- `combination` text NOT NULL,
6
- `archetype_index` text NOT NULL,
7
- `name` text NOT NULL,
8
- `essence_line` text NOT NULL,
9
- `description` text NOT NULL,
10
- `content` text DEFAULT '[]' NOT NULL,
11
- `virtues` text DEFAULT '[]' NOT NULL,
12
- `leonardo_prompt` text,
13
- `status` text DEFAULT 'idle',
14
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
15
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
16
- );
17
- --> statement-breakpoint
18
- CREATE INDEX `archetypes_data_language_idx` ON `archetypes_data` (`language`);--> statement-breakpoint
19
- CREATE INDEX `archetypes_data_combination_idx` ON `archetypes_data` (`combination`);--> statement-breakpoint
20
- CREATE INDEX `archetypes_data_archetype_index_idx` ON `archetypes_data` (`archetype_index`);--> statement-breakpoint
21
- CREATE INDEX `archetypes_data_gender_idx` ON `archetypes_data` (`gender`);--> statement-breakpoint
22
- ALTER TABLE `user_artifacts` ADD `archetype_data_id` text REFERENCES archetypes_data(id);--> statement-breakpoint
23
- CREATE INDEX `user_artifacts_archetype_data_id_idx` ON `user_artifacts` (`archetype_data_id`);
@@ -1 +0,0 @@
1
- ALTER TABLE `archetypes_data` ADD `images` text DEFAULT '[]' NOT NULL;
@@ -1,27 +0,0 @@
1
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
- CREATE TABLE `__new_archetypes_data` (
3
- `id` text PRIMARY KEY NOT NULL,
4
- `language` text NOT NULL,
5
- `gender` text,
6
- `combination` text NOT NULL,
7
- `archetype_index` text NOT NULL,
8
- `name` text NOT NULL,
9
- `essence_line` text NOT NULL,
10
- `description` text,
11
- `content` text DEFAULT '[]' NOT NULL,
12
- `virtues` text DEFAULT '[]' NOT NULL,
13
- `leonardo_prompt` text,
14
- `status` text DEFAULT 'idle',
15
- `created_at` integer DEFAULT CURRENT_TIMESTAMP,
16
- `images` text DEFAULT '[]' NOT NULL,
17
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP
18
- );
19
- --> statement-breakpoint
20
- INSERT INTO `__new_archetypes_data`("id", "language", "gender", "combination", "archetype_index", "name", "essence_line", "description", "content", "virtues", "leonardo_prompt", "status", "created_at", "images", "updated_at") SELECT "id", "language", "gender", "combination", "archetype_index", "name", "essence_line", "description", "content", "virtues", "leonardo_prompt", "status", "created_at", "images", "updated_at" FROM `archetypes_data`;--> statement-breakpoint
21
- DROP TABLE `archetypes_data`;--> statement-breakpoint
22
- ALTER TABLE `__new_archetypes_data` RENAME TO `archetypes_data`;--> statement-breakpoint
23
- PRAGMA foreign_keys=ON;--> statement-breakpoint
24
- CREATE INDEX `archetypes_data_language_idx` ON `archetypes_data` (`language`);--> statement-breakpoint
25
- CREATE INDEX `archetypes_data_combination_idx` ON `archetypes_data` (`combination`);--> statement-breakpoint
26
- CREATE INDEX `archetypes_data_archetype_index_idx` ON `archetypes_data` (`archetype_index`);--> statement-breakpoint
27
- CREATE INDEX `archetypes_data_gender_idx` ON `archetypes_data` (`gender`);
@@ -1,7 +0,0 @@
1
- CREATE TABLE `archetype_name_dumps` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `combination` text NOT NULL,
4
- `raw_text` text NOT NULL,
5
- `parsed_successfully` integer DEFAULT 0,
6
- `created_at` integer DEFAULT CURRENT_TIMESTAMP
7
- );
@@ -1,10 +0,0 @@
1
- CREATE TABLE `logs` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `level` text NOT NULL,
4
- `message` text NOT NULL,
5
- `context` text DEFAULT '{}' NOT NULL,
6
- `created_at` integer DEFAULT CURRENT_TIMESTAMP
7
- );
8
- --> statement-breakpoint
9
- ALTER TABLE `generations` ADD `archetype_data_id` text REFERENCES archetypes_data(id);--> statement-breakpoint
10
- CREATE INDEX `generations_archetype_data_id_idx` ON `generations` (`archetype_data_id`);
@@ -1,10 +0,0 @@
1
- ALTER TABLE `user_artifacts` RENAME COLUMN "post_image_id" TO "post_images";--> statement-breakpoint
2
- ALTER TABLE `user_artifacts` RENAME COLUMN "reel_image_id" TO "reel_images";--> statement-breakpoint
3
- ALTER TABLE `user_artifacts` ADD `concept_id` text NOT NULL REFERENCES concepts(id);--> statement-breakpoint
4
- CREATE INDEX `user_artifacts_concept_id_idx` ON `user_artifacts` (`concept_id`);--> statement-breakpoint
5
- ALTER TABLE `user_artifacts` DROP COLUMN `gender`;--> statement-breakpoint
6
- ALTER TABLE `user_artifacts` DROP COLUMN `archetype_index`;--> statement-breakpoint
7
- ALTER TABLE `user_artifacts` DROP COLUMN `post_image_url`;--> statement-breakpoint
8
- ALTER TABLE `user_artifacts` DROP COLUMN `reel_image_url`;--> statement-breakpoint
9
- ALTER TABLE `user_artifacts` DROP COLUMN `post_generation_id`;--> statement-breakpoint
10
- ALTER TABLE `user_artifacts` DROP COLUMN `reel_generation_id`;
@@ -1 +0,0 @@
1
- ALTER TABLE `user_artifacts` ADD `chosen_image_url` text;
@@ -1 +0,0 @@
1
- ALTER TABLE `user_artifacts` ADD `version` integer DEFAULT 0 NOT NULL;
@@ -1,16 +0,0 @@
1
- CREATE TABLE `cosmic_mirror_images` (
2
- `id` text PRIMARY KEY NOT NULL,
3
- `user_artifact_id` text NOT NULL,
4
- `leonardo_id` text NOT NULL,
5
- `url` text NOT NULL,
6
- `width` integer NOT NULL,
7
- `height` integer NOT NULL,
8
- `generation_type` text NOT NULL,
9
- `timestamp` integer NOT NULL,
10
- `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
11
- `updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,
12
- FOREIGN KEY (`user_artifact_id`) REFERENCES `user_artifacts`(`id`) ON UPDATE no action ON DELETE cascade
13
- );
14
- --> statement-breakpoint
15
- CREATE INDEX `cosmic_mirror_images_user_artifact_idx` ON `cosmic_mirror_images` (`user_artifact_id`);--> statement-breakpoint
16
- CREATE INDEX `cosmic_mirror_images_type_idx` ON `cosmic_mirror_images` (`generation_type`);