Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use final insert for migrations that create a new table #51

Open
mbyczkowski opened this issue Sep 18, 2018 · 1 comment
Open

Comments

@mbyczkowski
Copy link

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())
@michaelfinch
Copy link
Collaborator

That makes sense. The final insert was intended to be used to insert records into something like a schema_migrations table after a migration is run, but I agree that there's no reason shift shouldn't allow performing a final insert on a table that is created in the same migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants