Cannot use final insert for migrations that create a new table
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 737
- Forks
- 52
- Avg merge
- 4d 4h
- Merged PRs (30d)
- 1
Description
It seems that Shift tries to validate the migration and fails, because a table doesn't exist, but it would have existed after the DDL statement execution.
It would be nice if Shift could recognize this and appropriately validate the input.
Error I saw:
Error message: migration: invalid final insert statement: Error 1146: Table 'some_app_staging.ar_internal_metadata' doesn't exist.
My DDL statement:
CREATE TABLE
`ar_internal_metadata` (
`key` VARCHAR (255) CHARACTER
SET
utf8 COLLATE utf8_unicode_ci NOT NULL
,`value` VARCHAR (255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
,`created_at` datetime NOT NULL
,`updated_at` datetime NOT NULL
,PRIMARY KEY (`key`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
My final insert:
INSERT INTO `ar_internal_metadata` (`key`, `value`, `created_at`, `updated_at`)
VALUES ('environment', 'staging', NOW(), NOW())
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Shift's migration validation for final INSERT statements and reproduce the report using the supplied CREATE TABLE and INSERT on MySQL. Trace why validation checks the table before the DDL has taken effect; done means a migration that creates ar_internal_metadata accepts the final insert while still rejecting genuinely invalid references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, ruby
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100