@famgia/omnify-laravel 0.0.110 → 0.0.112

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@famgia/omnify-laravel",
3
- "version": "0.0.110",
3
+ "version": "0.0.112",
4
4
  "description": "Laravel migration and TypeScript type generator for omnify-schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,9 +25,9 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
- "@famgia/omnify-types": "0.0.99",
29
- "@famgia/omnify-core": "0.0.101",
30
- "@famgia/omnify-atlas": "0.0.95"
28
+ "@famgia/omnify-types": "0.0.101",
29
+ "@famgia/omnify-atlas": "0.0.97",
30
+ "@famgia/omnify-core": "0.0.103"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup",
@@ -7,7 +7,7 @@ alwaysApply: false
7
7
  # Laravel Rules
8
8
 
9
9
  > **Documentation:** `.claude/guides/laravel/`
10
- > **Specific Rules:** See also `laravel-controller.mdc`, `laravel-resource.mdc`, `laravel-request.mdc`, `laravel-testing.mdc`, `omnify-migrations.mdc`
10
+ > **Specific Rules:** See also `laravel-controller.mdc`, `laravel-resource.mdc`, `laravel-request.mdc`, `laravel-testing.mdc`, `migrations-workflow.mdc`, `omnify-migrations.mdc`
11
11
 
12
12
  ## ⛔ CRITICAL: DO NOT EDIT
13
13
 
@@ -25,7 +25,7 @@ alwaysApply: false
25
25
  ## Critical Rules
26
26
 
27
27
  1. **Thin Controller** - Validate → Delegate → Respond (see `laravel-controller.mdc`)
28
- 2. **Schema-First** - Use Omnify schemas, don't create migrations manually
28
+ 2. **🚨 Schema-First** - **NEVER** run `php artisan make:migration`! Use Omnify schemas instead (see `migrations-workflow.mdc`)
29
29
  3. **Security** - Always use `$request->validated()`, never `$request->all()`
30
30
  4. **Performance** - Use `with()` for relations, `paginate()` for lists
31
31
  5. **Dates** - Store UTC, return `->toISOString()`
@@ -33,6 +33,21 @@ alwaysApply: false
33
33
  7. **Imports** - Always `use` and short class names, never FQCN inline
34
34
  8. **OpenAPI Paths** - NO `/api` prefix! `api.php` already has it (see `laravel-controller.mdc`)
35
35
 
36
+ ## ⛔ FORBIDDEN: Manual Migrations
37
+
38
+ ```bash
39
+ # ❌ NEVER DO THIS
40
+ php artisan make:migration create_xxx_table
41
+ php artisan make:migration add_xxx_to_xxx_table
42
+
43
+ # ✅ ALWAYS DO THIS
44
+ # 1. Edit/Create YAML schema in schemas/
45
+ # 2. Run: npx omnify generate
46
+ # 3. Run: php artisan migrate
47
+ ```
48
+
49
+ See `migrations-workflow.mdc` for complete guide.
50
+
36
51
  ## File-Specific Rules
37
52
 
38
53
  | File Type | Rule File | Key Focus |
@@ -0,0 +1,224 @@
1
+ ---
2
+ description: "CRITICAL: Use Omnify Schema for migrations - DO NOT create migrations manually"
3
+ globs: ["{{LARAVEL_BASE}}/database/migrations/**"]
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # ⛔ STOP: DO NOT CREATE MIGRATIONS MANUALLY
8
+
9
+ ## You MUST use Omnify Schema to create database changes
10
+
11
+ When you need to modify the database structure, **NEVER** run:
12
+
13
+ ```bash
14
+ # ❌ FORBIDDEN
15
+ php artisan make:migration create_xxx_table
16
+ php artisan make:migration add_xxx_to_xxx_table
17
+ php artisan make:migration modify_xxx_column
18
+ ```
19
+
20
+ ---
21
+
22
+ ## ✅ CORRECT WORKFLOW
23
+
24
+ ### Step 1: Create or Edit Schema YAML
25
+
26
+ ```yaml
27
+ # schemas/your-module/YourModel.yaml
28
+ displayName:
29
+ ja: モデル名
30
+ en: Model Name
31
+
32
+ properties:
33
+ field_name:
34
+ type: String
35
+ length: 255
36
+ displayName:
37
+ ja: フィールド名
38
+ en: Field Name
39
+ ```
40
+
41
+ ### Step 2: Generate Migrations
42
+
43
+ ```bash
44
+ npx omnify generate
45
+ ```
46
+
47
+ ### Step 3: Run Migrations
48
+
49
+ ```bash
50
+ php artisan migrate
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Why This Rule Exists
56
+
57
+ | Manual Migration | Omnify Schema |
58
+ |------------------|---------------|
59
+ | ❌ No TypeScript types | ✅ Auto-generated types |
60
+ | ❌ No i18n labels | ✅ Auto-generated i18n |
61
+ | ❌ No Zod validation | ✅ Auto-generated validation |
62
+ | ❌ No API resources | ✅ Auto-generated API |
63
+ | ❌ Inconsistent naming | ✅ Consistent naming |
64
+ | ❌ Manual model updates | ✅ Auto-updated models |
65
+
66
+ ---
67
+
68
+ ## Schema-First Development Flow
69
+
70
+ ```
71
+ ┌─────────────────────────────────────────────────────────────┐
72
+ │ SCHEMA YAML (Source of Truth) │
73
+ │ schemas/module/ModelName.yaml │
74
+ └─────────────────────┬───────────────────────────────────────┘
75
+
76
+ ▼ npx omnify generate
77
+ ┌────────────┴────────────┬─────────────────┐
78
+ ▼ ▼ ▼
79
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
80
+ │ Migrations │ │ Laravel │ │ TypeScript │
81
+ │ (PHP) │ │ Models │ │ Types/Zod │
82
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
83
+ │ │ │
84
+ ▼ ▼ ▼
85
+ php artisan Ready to use Frontend ready
86
+ migrate
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 🚨 BEFORE Creating Any Migration
92
+
93
+ ### Ask yourself:
94
+
95
+ 1. **Can this be done with Omnify Schema?**
96
+ - New table? → Create new YAML schema
97
+ - New column? → Add property to YAML
98
+ - New index? → Add `index: true` to property
99
+ - Foreign key? → Add association to YAML
100
+
101
+ 2. **Is this schema-related?**
102
+ - YES → Edit YAML, run `npx omnify generate`
103
+ - NO → Only then consider manual migration
104
+
105
+ ---
106
+
107
+ ## When Manual Migrations ARE Allowed
108
+
109
+ Only for operations **NOT supported** by Omnify:
110
+
111
+ ```bash
112
+ # ✅ ALLOWED: Data migrations (not schema changes)
113
+ php artisan make:migration migrate_old_data_to_new_format
114
+
115
+ # ✅ ALLOWED: Complex SQL operations
116
+ php artisan make:migration add_full_text_search_index
117
+
118
+ # ✅ ALLOWED: Third-party package migrations
119
+ php artisan vendor:publish --tag=package-migrations
120
+ ```
121
+
122
+ **BUT NEVER for standard CRUD tables/columns!**
123
+
124
+ ---
125
+
126
+ ## Quick Reference: Schema vs Manual
127
+
128
+ | Change Type | Use Omnify Schema | Manual OK |
129
+ |-------------|:-----------------:|:---------:|
130
+ | Create table | ✅ | ❌ |
131
+ | Add column | ✅ | ❌ |
132
+ | Modify column | ✅ | ❌ |
133
+ | Add foreign key | ✅ | ❌ |
134
+ | Add simple index | ✅ | ❌ |
135
+ | Add pivot table | ✅ | ❌ |
136
+ | Add enum column | ✅ | ❌ |
137
+ | Data migration | ❌ | ✅ |
138
+ | Full-text index | ❌ | ✅ |
139
+ | Raw SQL changes | ❌ | ✅ |
140
+
141
+ ---
142
+
143
+ ## How to Add Common Schema Changes
144
+
145
+ ### New Table
146
+
147
+ ```yaml
148
+ # schemas/shop/Product.yaml
149
+ displayName:
150
+ ja: 商品
151
+ en: Product
152
+
153
+ properties:
154
+ name:
155
+ type: String
156
+ length: 255
157
+ price:
158
+ type: Decimal
159
+ precision: 10
160
+ scale: 2
161
+ ```
162
+
163
+ ### New Column to Existing Table
164
+
165
+ ```yaml
166
+ # Edit existing schemas/shop/Product.yaml
167
+ properties:
168
+ # ... existing properties ...
169
+
170
+ # Add new property
171
+ sku:
172
+ type: String
173
+ length: 50
174
+ unique: true
175
+ ```
176
+
177
+ ### Add Relationship
178
+
179
+ ```yaml
180
+ # schemas/shop/Product.yaml
181
+ associations:
182
+ category:
183
+ type: ManyToOne
184
+ target: Category
185
+ foreignKey: category_id
186
+ ```
187
+
188
+ ### Add Index
189
+
190
+ ```yaml
191
+ properties:
192
+ email:
193
+ type: String
194
+ index: true # Simple index
195
+
196
+ # Or composite index
197
+ indexes:
198
+ - columns: [first_name, last_name]
199
+ unique: true
200
+ ```
201
+
202
+ ---
203
+
204
+ ## Remember
205
+
206
+ > **Schema YAML = Single Source of Truth**
207
+ >
208
+ > All database structure changes should originate from YAML schemas.
209
+ > The migration files are just **generated output**, not the source.
210
+
211
+ ---
212
+
213
+ ## If You're Unsure
214
+
215
+ Read the schema guide:
216
+
217
+ ```bash
218
+ cat .cursor/rules/omnify/schema-create.mdc
219
+ # or
220
+ cat schemas/README.md
221
+ ```
222
+
223
+ Or ask:
224
+ > "How do I add [field/table/relationship] using Omnify schema?"