Skip to content

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

@mbyczkowski

Description

@mbyczkowski

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions