trypost/database/migrations
Jamie Ontiveros 02425038aa
Make the test suite pass on MySQL (#307)
* Give the foreign key a backing index before dropping the unique

social_accounts.workspace_id carries a foreign key, and the composite
unique index is the only one covering it, as its leftmost prefix. MySQL
refuses to drop the sole index backing a foreign key (SQLSTATE[HY000]
1553), so both rehearsal suites failed in beforeEach and never ran a
single assertion on MySQL. Add a plain index on workspace_id first;
PostgreSQL has no such requirement and simply carries it.

This unmasks one assertion underneath that had never executed: the
automation graph comparison at DuplicateIdentityMigrationTest.php:419
depended on JSON object key order, which MySQL normalises on storage.

(cherry picked from commit 98a494bd2205e873321a18232f63b358ae259fdf)

* Compare JSON payloads without depending on key order

MySQL normalises JSON object keys (length, then lexicographic) on
storage, so an identity comparison against a literal asserts how the
driver chose to lay the object out rather than what it contains.
PostgreSQL preserves insertion order, which is why these passed there.

toEqual compares associative arrays recursively without regard to key
order. Applied to every assertion in this class, including the few that
pass today only because their keys already happen to match MySQL's
ordering.

(cherry picked from commit 3124023c548d6c2b8b52126afc6fc5f38d461ea6)

* Match logged SQL without depending on identifier quoting

Four DB::listen predicates matched 'select * from "post_platforms"'.
PostgreSQL quotes identifiers with double quotes and MySQL with
backticks, so on MySQL the predicates never matched, the simulated
mid-run pause never fired, and the race these tests exist to cover went
unexercised while the tests still reported failures elsewhere.

Compare against the unquoted form via a small helper.

(cherry picked from commit 67a81df5de155e80227df748b34cd8b3cfd744f9)

* Cast raw boolean reads in tests so they pass on MySQL

Three assertions read oauth_refresh_tokens.revoked through the query
builder rather than Eloquent, so no cast applies and the driver's native
representation leaks into the test: a real boolean on PostgreSQL, 1 on
MySQL. Cast explicitly at the call site.

(cherry picked from commit 2911c5c48cf65d24a34a41e667335c40005839a7)

* Use a scheduling date inside MySQL's TIMESTAMP range

MySQL TIMESTAMP columns end at 2038-01-19, so the 2099 sentinel these
tests used is rejected outright with SQLSTATE[22007]. 2037-12-31 still
reads as a far-future schedule and works on both engines.

(cherry picked from commit bde33eb239cdbd3a5567d4c21e1d85302913cdd7)

* Remove the duplicate-identity migration scenario test

The suite rebuilt a pre-migration schema by dropping the unique index in
beforeEach and re-running the migration by hand, exercising a database
state the application never runs in.

* Fix the MySQL rollback path and run CI on both engines

The migration's down() dropped a unique whose leftmost prefix is an FK
column, which MySQL refuses when nothing else backs the constraint
(SQLSTATE 1553). It now creates a standalone index first, so
migrate:rollback works on MySQL and stays a no-op change for PostgreSQL.
up() is untouched: every database already migrated keeps its schema.

The rehearsal test calls that down() instead of hand-rolling the drop,
so it exercises the real rollback rather than an imitation of it.

Matches logged SQL through the connection's query grammar rather than
stripping quote characters, and adds a MySQL leg to the backend CI job.

* Use a readiness check both database images can run

mysql:8.4 installs mysql-community-server-minimal, which ships neither
mysqladmin nor the mysql client, so a mysqladmin health command never
succeeds and the service never reports healthy. Both images run their
init phase without networking, so an open port is the point either
engine starts accepting connections - one check covers both, and the
per-engine matrix key goes away.

* Use each engine's own readiness tool

pg_isready and mysqladmin ping are what the respective images ship for
this, and the mysql image's entrypoint invokes mysqladmin itself, so it
is present. Keeps 20 retries, which MySQL needs to finish initialising.

* State the two-engine ceiling as a rule, not a test detail

The 2038 TIMESTAMP limit binds anything written to the column, not just
the sentinel dates in fixtures, and the same reasoning generalises: what
the app supports is the intersection of both engines.

* Let the release image connect to MySQL

The published image installed only pdo_pgsql, so DB_CONNECTION=mysql
failed with "could not find driver" before any query ran - the app
supports MySQL but the image people actually deploy could not reach it.
mysql-client mirrors the postgresql-client already present, for
artisan db and dumps.

* Keep "backend" a single required status check

Matrixing the job split its check in two, so the "backend" context the
branch protection requires was never reported and every PR sat waiting
on it. The matrix is now "tests" and a small "backend" job gates on it,
which keeps the required check stable however many engines the matrix
grows to - and leaves the open PRs mergeable without a rebase.

---------

Co-authored-by: Paulo Castellano <paulo@castellanos.llc>
2026-08-29 11:05:33 -03:00
..
0001_01_01_000000_create_users_table.php feat: implement consolidated authentication settings including session management and social provider integration 2026-05-03 17:42:44 -03:00
0001_01_01_000001_create_cache_table.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
0001_01_01_000002_create_jobs_table.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
2026_01_14_231039_create_plans_table.php feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
2026_01_14_231040_create_accounts_table.php feat: redesign billing, onboarding, sidebar, and settings architecture 2026-04-15 00:33:38 -03:00
2026_01_14_232315_create_workspaces_table.php feat: replace legacy AI assistant with modular post content generation, review, and template management system 2026-05-03 09:36:50 -03:00
2026_01_14_232317_create_subscriptions_table.php feat: introduce Account entity as billing owner and refactor architecture 2026-04-14 22:22:04 -03:00
2026_01_14_232318_create_subscription_items_table.php refactor: consolidate billing migrations into original files 2026-04-14 18:59:43 -03:00
2026_01_14_232319_create_user_workspace_table.php refactor: consolidate billing migrations into original files 2026-04-14 18:59:43 -03:00
2026_01_14_232320_create_social_accounts_table.php feat: implement paginated social accounts table with search functionality and updated UI components 2026-05-02 14:15:41 -03:00
2026_01_14_232321_create_posts_table.php Change media column to nullable with default null 2026-05-19 08:19:40 +02:00
2026_01_14_232322_create_post_platforms_table.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
2026_01_14_232323_create_medias_table.php refactor: consolidate billing migrations into original files 2026-04-14 18:59:43 -03:00
2026_01_14_233835_create_workspace_invites_table.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
2026_01_17_152319_create_workspace_signatures_table.php chore: remove deprecated localization files 2026-05-03 15:23:25 -03:00
2026_01_17_153347_create_workspace_labels_table.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
2026_01_26_173538_create_post_workspace_label_table.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
2026_03_29_233024_create_telescope_entries_table.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
2026_03_30_024008_replace_language_id_with_locale_on_users.php refactor: settings redesign, Spanish translations, language system, strict_types 2026-03-30 00:20:43 -03:00
2026_03_30_115716_drop_locale_from_users.php refactor: auth split layout, subscribe redesign, onboarding, i18n, cookie locale 2026-03-30 11:53:42 -03:00
2026_03_30_120000_add_indexes_to_post_platforms.php feat: PostPlatform enum, failure email, DB indexes, rate limiting, tests 2026-03-30 16:11:38 -03:00
2026_03_30_191151_create_notifications_table.php feat: add PostCommentCreated broadcast event 2026-04-15 20:11:36 -03:00
2026_03_30_202513_create_notification_preferences_table.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
2026_03_30_215118_add_is_active_to_social_accounts.php chore: posthog, ui, features and more 2026-03-30 21:18:07 -03:00
2026_04_15_000001_create_post_comments_table.php Change reactions column to nullable with default null 2026-05-19 08:28:07 +02:00
2026_04_15_000003_create_workspace_ai_usages_table.php feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
2026_05_03_210117_create_oauth_auth_codes_table.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
2026_05_03_210118_create_oauth_access_tokens_table.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
2026_05_03_210119_create_oauth_refresh_tokens_table.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
2026_05_03_210120_create_oauth_clients_table.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
2026_05_03_210121_create_oauth_device_codes_table.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
2026_05_04_212145_add_utm_columns_to_users_table.php feat: capture signup UTMs/IP and add GitHub OAuth login 2026-05-04 18:42:25 -03:00
2026_05_04_212935_add_github_id_to_users_table.php feat: capture signup UTMs/IP and add GitHub OAuth login 2026-05-04 18:42:25 -03:00
2026_05_04_212935_add_registration_ip_to_users_table.php feat: capture signup UTMs/IP and add GitHub OAuth login 2026-05-04 18:42:25 -03:00
2026_05_07_231552_add_image_style_to_workspaces_table.php feat: AI image generation pipeline and post creation overhaul 2026-05-08 13:38:30 -03:00
2026_05_15_190137_add_upload_token_to_media_table.php style(media): add void return on migration closures, drop noop ->after 2026-05-15 16:06:54 -03:00
2026_05_22_211640_create_automations_table.php Tidy automation backend: run duration, folded migrations, imports 2026-06-13 16:30:32 -03:00
2026_05_22_211641_create_automation_trigger_items_table.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
2026_05_22_211642_create_automation_runs_table.php Tidy automation backend: run duration, folded migrations, imports 2026-06-13 16:30:32 -03:00
2026_05_22_211643_create_automation_node_runs_table.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
2026_05_23_164734_create_automation_node_states_table.php Add strict_types to automation files and AutomationNodeState factory 2026-06-10 17:26:50 -03:00
2026_06_12_155847_replace_brand_voice_notes_with_traits_on_workspaces.php Structure brand voice and make generated copy platform-aware 2026-06-12 17:09:39 -03:00
2026_06_21_184042_drop_limit_columns_from_plans_table.php refactor: address code review for per-workspace pricing 2026-06-21 21:28:47 -03:00
2026_06_21_194741_add_persona_to_users_table.php refactor: address code review for per-workspace pricing 2026-06-21 21:28:47 -03:00
2026_06_22_162523_drop_features_table.php chore: remove unused Pennant package and dead user-timezone handling 2026-06-22 13:37:38 -03:00
2026_06_24_220651_collapse_linkedin_content_types.php refactor(linkedin): infer post format from media + unify account connection 2026-06-24 21:05:09 -03:00
2026_06_25_232554_add_goals_to_users_table.php feat(onboarding): add goal step after persona 2026-06-25 20:49:04 -03:00
2026_07_18_184130_add_referral_source_to_users_table.php feat(onboarding): add "where you found us" referral-source step 2026-07-18 16:07:11 -03:00
2026_07_24_141454_add_created_via_to_posts_table.php chore: added strict types 2026-07-24 11:22:28 -03:00
2026_07_24_160704_add_onboarding_timestamps_to_accounts_table.php Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
2026_07_29_183500_backfill_onboarding_dismissed_for_accounts_with_app_access.php Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
2026_08_06_144847_add_workspace_id_to_oauth_auth_codes_table.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
2026_08_06_144848_backfill_mcp_oauth_token_workspaces.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
2026_08_08_090000_add_connection_warning_sent_at_to_post_platforms_table.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
2026_08_08_204549_add_last_verified_at_to_social_accounts_table.php feat: proactive connection check for at-risk posts + SocialAccount name centralization (#256) 2026-08-09 11:10:39 -03:00
2026_08_11_171700_add_click_id_columns_to_users_table.php feat: capture ad click IDs for ad-platform conversion attribution (#276) 2026-08-11 15:07:23 -03:00
2026_08_21_130941_add_workspace_platform_identity_unique_to_social_accounts_table.php Make the test suite pass on MySQL (#307) 2026-08-29 11:05:33 -03:00