Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 0445342

Browse files
bpamiriclaude
andcommitted
Use raw SQL in migrations to bypass addRecord boolean-to-int conversion
The Wheels framework addRecord() converts boolean true/false to integer 1/0 via IsNumeric() and IIf(), which CockroachDB rejects for boolean columns. Replaced all addRecord() calls containing boolean values with execute() using raw INSERT statements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2bb097 commit 0445342

3 files changed

Lines changed: 63 additions & 62 deletions

File tree

app/migrator/migrations/20250306112302_insert_records.cfc

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ component extends="wheels.migrator.Migration" hint="insert records" {
88
addRecord(table='Roles',name = "editor");
99
addRecord(table='Roles',name = "user");
1010

11-
// users
12-
addRecord(table="users", first_name="Peter", last_name="Amiri", email="petera@pai.com", password_hash="$2a$10$P27CV/m.aramHhIxJTmzzu4dxIGfNqHWzLgVGJJTLDpXymnt4jPZu", profile_picture='avatar-rounded.webp', profile_url='', status=true, role_id=1);
11+
// users (use execute() because addRecord converts booleans to integers which CockroachDB rejects)
12+
execute("INSERT INTO users (first_name, last_name, email, password_hash, profile_picture, profile_url, status, role_id, createdat, updatedat) VALUES ('Peter', 'Amiri', 'petera@pai.com', '$2a$10$P27CV/m.aramHhIxJTmzzu4dxIGfNqHWzLgVGJJTLDpXymnt4jPZu', 'avatar-rounded.webp', '', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
1313

1414
// categories
1515
addRecord(table='categories', name='CLI', parent_id='', description='Learn about command-line tools, tips, and tricks for enhancing your development workflow using the command line.');
@@ -24,42 +24,42 @@ component extends="wheels.migrator.Migration" hint="insert records" {
2424
addRecord(table='categories', name='Tutorials', parent_id='', description='Step-by-step guides and how-tos for beginners and advanced users alike, covering a wide range of topics.');
2525
addRecord(table='categories', name='Website', parent_id='', description='News, updates, and improvements related to the website, including UI/UX enhancements and new features.');
2626

27-
// post_types
28-
addRecord(table='post_types', name='Standard Post', description='Regular blog post with a title, content, and optional featured image.', is_active=true);
29-
addRecord(table='post_types', name='Video Post', description='Contains embedded videos from platforms like YouTube.', is_active=true);
30-
addRecord(table='post_types', name='Gallery Post', description='Displays multiple images in a gallery or slideshow format.', is_active=true);
31-
addRecord(table='post_types', name='Audio Post', description='Includes audio players for podcasts or music.', is_active=true);
32-
addRecord(table='post_types', name='Quote Post', description='Highlights a specific quote with proper attribution.', is_active=true);
33-
addRecord(table='post_types', name='Link Post', description='Focuses on sharing a link with a brief description.', is_active=true);
34-
addRecord(table='post_types', name='Status Post', description='Short, social media-style updates or announcements.', is_active=true);
35-
addRecord(table='post_types', name='Review Post', description='Reviews of products, services, or experiences with a rating system.', is_active=true);
36-
addRecord(table='post_types', name='Tutorial/How-to Post', description='Step-by-step guides or instructional content.', is_active=true);
37-
addRecord(table='post_types', name='News Post', description='Updates or news articles relevant to the audience.', is_active=true);
38-
addRecord(table='post_types', name='Interview Post', description='Q&A format featuring interviews with experts or influencers.', is_active=true);
39-
addRecord(table='post_types', name='Case Study Post', description='In-depth analysis or success stories.', is_active=true);
40-
addRecord(table='post_types', name='List Post', description='Lists of tips, resources, or best practices (e.g., "Top 10...").', is_active=true);
41-
addRecord(table='post_types', name='Event Post', description='Announcements or recaps of events, workshops, or webinars.', is_active=true);
42-
addRecord(table='post_types', name='Opinion Post', description='Editorial or opinion pieces.', is_active=true);
27+
// post_types (use execute() for boolean is_active column)
28+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Standard Post', 'Regular blog post with a title, content, and optional featured image.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
29+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Video Post', 'Contains embedded videos from platforms like YouTube.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
30+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Gallery Post', 'Displays multiple images in a gallery or slideshow format.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
31+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Audio Post', 'Includes audio players for podcasts or music.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
32+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Quote Post', 'Highlights a specific quote with proper attribution.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
33+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Link Post', 'Focuses on sharing a link with a brief description.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
34+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Status Post', 'Short, social media-style updates or announcements.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
35+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Review Post', 'Reviews of products, services, or experiences with a rating system.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
36+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Tutorial/How-to Post', 'Step-by-step guides or instructional content.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
37+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('News Post', 'Updates or news articles relevant to the audience.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
38+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Interview Post', 'Q&A format featuring interviews with experts or influencers.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
39+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Case Study Post', 'In-depth analysis or success stories.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
40+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('List Post', 'Lists of tips, resources, or best practices (e.g., ''Top 10...'').', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
41+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Event Post', 'Announcements or recaps of events, workshops, or webinars.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
42+
execute("INSERT INTO post_types (name, description, is_active, createdat, updatedat) VALUES ('Opinion Post', 'Editorial or opinion pieces.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
4343

44-
// post_statuses
45-
addRecord(table='post_statuses', name='Draft', description='Post is saved but not published. Only visible to admins and authors.', is_active=true);
46-
addRecord(table='post_statuses', name='Posted', description='Post is live and visible to the public.', is_active=true);
47-
addRecord(table='post_statuses', name='Scheduled', description='Post is set to go live at a future date/time.', is_active=true);
48-
addRecord(table='post_statuses', name='Pending Review', description='Post is awaiting review and approval before publishing.', is_active=true);
49-
addRecord(table='post_statuses', name='Archived', description='Post is no longer public but saved for record-keeping.', is_active=true);
50-
addRecord(table='post_statuses', name='Private', description='Post is only visible to specific users (e.g., admins or logged-in users).', is_active=true);
51-
addRecord(table='post_statuses', name='Trash', description='Post is marked for deletion but can be restored or permanently deleted later.', is_active=true);
44+
// post_statuses (use execute() for boolean is_active column)
45+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Draft', 'Post is saved but not published. Only visible to admins and authors.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
46+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Posted', 'Post is live and visible to the public.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
47+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Scheduled', 'Post is set to go live at a future date/time.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
48+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Pending Review', 'Post is awaiting review and approval before publishing.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
49+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Archived', 'Post is no longer public but saved for record-keeping.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
50+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Private', 'Post is only visible to specific users (e.g., admins or logged-in users).', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
51+
execute("INSERT INTO post_statuses (name, description, is_active, createdat, updatedat) VALUES ('Trash', 'Post is marked for deletion but can be restored or permanently deleted later.', true, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
5252

53-
// features
54-
addRecord(table="features", title="A Complete Package", description="A full framework with tonnes of functionality - once you've started, you'll wonder how you ever did CFML development before!", is_active=true, created_by=1);
55-
addRecord(table="features", title="RESTful Routing", description="<a href='https://guides.cfwheels.org/cfwheels-guides/handling-requests-with-controllers/routing'>Resource based routing</a> for GET, POST, PUT, PATCH &amp; DELETE", is_active=true, created_by=1);
56-
addRecord(table="features", title="Database Migrations", description="Built in <a href='https://guides.cfwheels.org/cfwheels-guides/database-interaction-through-models/database-migrations'>database migration system</a> even across different DBMS", is_active=true, created_by=1);
57-
addRecord(table="features", title="Automatic Documentation", description="Use our <a href='https://guides.cfwheels.org/cfwheels-guides/working-with-cfwheels/documenting-your-code'>built in doc viewer</a> which grows with your application with only minor markup required", is_active=true, created_by=1);
58-
addRecord(table="features", title="Hybrid Development", description="Switch in and out of Wheels conventions - it's your call; Need to use a bog standard query? Go ahead!", is_active=true, created_by=1);
59-
addRecord(table="features", title="Full Documentation", description="Lots of lovely <a href='https://guides.cfwheels.org/' title='Documentation'>documentation</a> available with <a href='https://guides.cfwheels.org/cfwheels-guides/introduction/readme/beginner-tutorial-hello-world'>tutorials</a> and a <a href='https://api.cfwheels.org/''>complete API reference</a>", is_active=true, created_by=1);
60-
addRecord(table="features", title="Stay Relevant", description="Wheels uses industry established concepts, such as <a href='https://guides.cfwheels.org/cfwheels-guides/introduction/frameworks-and-cfwheels'>MVC</a> and <a href='https://guides.cfwheels.org/cfwheels-guides/database-interaction-through-models/object-relational-mapping'>ORM</a>. These essential principles make being a polyglot a reality!", is_active=true, created_by=1);
61-
addRecord(table="features", title="A Helpful Community", description="Get in touch via our <a href='https://github.com/wheels-dev/wheels/discussions'>GitHub Discussions</a> - we're newbie friendly and just want to help out.", is_active=true, created_by=1);
62-
addRecord(table="features", title="Good Organization", description="Stop thinking about how to organize your code and deal with your business specific problems instead.", is_active=true, created_by=1);
53+
// features (use execute() for boolean is_active column)
54+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('A Complete Package', 'A full framework with tonnes of functionality - once you''ve started, you''ll wonder how you ever did CFML development before!', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
55+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('RESTful Routing', '<a href=''https://guides.cfwheels.org/cfwheels-guides/handling-requests-with-controllers/routing''>Resource based routing</a> for GET, POST, PUT, PATCH &amp; DELETE', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
56+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Database Migrations', 'Built in <a href=''https://guides.cfwheels.org/cfwheels-guides/database-interaction-through-models/database-migrations''>database migration system</a> even across different DBMS', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
57+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Automatic Documentation', 'Use our <a href=''https://guides.cfwheels.org/cfwheels-guides/working-with-cfwheels/documenting-your-code''>built in doc viewer</a> which grows with your application with only minor markup required', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
58+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Hybrid Development', 'Switch in and out of Wheels conventions - it''s your call; Need to use a bog standard query? Go ahead!', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
59+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Full Documentation', 'Lots of lovely <a href=''https://guides.cfwheels.org/'' title=''Documentation''>documentation</a> available with <a href=''https://guides.cfwheels.org/cfwheels-guides/introduction/readme/beginner-tutorial-hello-world''>tutorials</a> and a <a href=''https://api.cfwheels.org/''>complete API reference</a>', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
60+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Stay Relevant', 'Wheels uses industry established concepts, such as <a href=''https://guides.cfwheels.org/cfwheels-guides/introduction/frameworks-and-cfwheels''>MVC</a> and <a href=''https://guides.cfwheels.org/cfwheels-guides/database-interaction-through-models/object-relational-mapping''>ORM</a>. These essential principles make being a polyglot a reality!', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
61+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('A Helpful Community', 'Get in touch via our <a href=''https://github.com/wheels-dev/wheels/discussions''>GitHub Discussions</a> - we''re newbie friendly and just want to help out.', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
62+
execute("INSERT INTO features (title, description, is_active, created_by, createdat, updatedat) VALUES ('Good Organization', 'Stop thinking about how to organize your code and deal with your business specific problems instead.', true, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)");
6363

6464
} catch (any e) {
6565
local.exception = e;

0 commit comments

Comments
 (0)