Skip to content

Commit 469a2e1

Browse files
docs: Add table definition type changes to Phase 1
- Add section on updating type names in table definitions - Include before/after code example - Add complete type mapping table (native → core types) - Update AI prompt to include type detection - Add grep pattern to find native types in definitions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e426f09 commit 469a2e1

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

src/how-to/migrate-from-0x.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,52 @@ Update Python code. No database changes.
102102
| `.fetch(as_dict=True)` | `.to_dicts()` |
103103
| `.fetch(format='frame')` | `.to_pandas()` |
104104

105+
### Table Definition Types
106+
107+
Update type names in your table definitions to use DataJoint core types:
108+
109+
```python
110+
# 0.x — native database types
111+
@schema
112+
class Session(dj.Manual):
113+
definition = """
114+
session_id : int unsigned
115+
---
116+
subject_id : int
117+
weight : float
118+
age_days : smallint unsigned
119+
is_active : tinyint(1)
120+
"""
121+
122+
# 2.0 — DataJoint core types
123+
@schema
124+
class Session(dj.Manual):
125+
definition = """
126+
session_id : uint32
127+
---
128+
subject_id : int32
129+
weight : float64
130+
age_days : uint16
131+
is_active : bool
132+
"""
133+
```
134+
135+
| 0.x (native) | 2.0 (core type) |
136+
|--------------|-----------------|
137+
| `int` | `int32` |
138+
| `int unsigned` | `uint32` |
139+
| `smallint` | `int16` |
140+
| `smallint unsigned` | `uint16` |
141+
| `tinyint` | `int8` |
142+
| `tinyint unsigned` | `uint8` |
143+
| `bigint` | `int64` |
144+
| `bigint unsigned` | `uint64` |
145+
| `float` | `float32` |
146+
| `double` | `float64` |
147+
| `tinyint(1)` | `bool` |
148+
| `longblob` | `<blob>` |
149+
| `blob@store` | `<blob@store>` |
150+
105151
### AI-Assisted Code Conversion
106152

107153
We recommend using an AI coding assistant (Claude Code, Cursor, GitHub Copilot)
@@ -114,7 +160,9 @@ Search for:
114160
1. .fetch('KEY') calls — replace with .keys()
115161
2. .fetch(as_dict=True) calls — replace with .to_dicts()
116162
3. .fetch(format='frame') calls — replace with .to_pandas()
117-
4. Any other deprecated fetch patterns
163+
4. Table definitions using native types (int, float, smallint, etc.)
164+
— replace with core types (int32, float64, int16, etc.)
165+
5. Any other deprecated patterns
118166
119167
For each file, show me the changes needed before applying them.
120168
```
@@ -125,6 +173,7 @@ For each file, show me the changes needed before applying them.
125173
grep -rn "\.fetch('KEY')" --include="*.py"
126174
grep -rn "fetch(as_dict=True)" --include="*.py"
127175
grep -rn "fetch(format=" --include="*.py"
176+
grep -rn "definition\s*=" --include="*.py" -A 20 | grep -E ":\s*(int|float|smallint|tinyint|bigint|double)"
128177
```
129178

130179
**Rollback:** `git checkout` to revert code.

0 commit comments

Comments
 (0)