Skip to content

Wrench should not add ON DELETE NO ACTION syntax #95

@graeme-verticalscope

Description

@graeme-verticalscope

Expected Behavior

When a table is created with a foreign key constraint and no foreign key action is provided, wrench should not add ON DELETE NO ACTION to the create table statement.

Current Behavior

Wrench adds ON DELETE NO ACTION, changing the statement syntax.

Steps to Reproduce

  1. Create 2 migration scripts
    script 1:
    CREATE TABLE Table1 (
      Table1ID STRING(MAX) NOT NULL,
    ) PRIMARY KEY(Table1ID);
    
    script 2:
    CREATE TABLE Table2 (
        Table2ID STRING(MAX) NOT NULL,
        Table1ID STRING(MAX) NOT NULL,
        CONSTRAINT FK_Table1Table2 FOREIGN KEY(Table1ID) REFERENCES Table1(Table1ID)
    ) PRIMARY KEY(Table2ID);
    
  2. Create a local spanner instance with cloud spanner emulator
  3. Apply migrations to cloud spanner emulator using wrench.
  4. Second migration fails with the following error:
    Foreign key referential action ON DELETE NO ACTION is not supported.
    
    This error demonstrates that ON DELETE NO ACTION is being added by wrench. If it wasn't being added by wrench, then second migration would succeed.

Context (Environment)

  • wrench version: v1.6.0
  • possibly caused by dependency cloud.google.com/go/spanner upgrade from v1.47.0 to v1.49.0
    • I can reproduce with wrench v1.5.0 if I upgrade cloud.google.com/go/spanner to v1.49.0.

This change breaks my local and CI environments that use the emulator:

  • The emulator does not accept create table statements with foreign key actions
  • I cannot remove the foreign key action, since it's being added by wrench.

I have already created an issue in cloud spanner emulator: GoogleCloudPlatform/cloud-spanner-emulator#142 but I was told the fix should be on the wrench side, not the emulator side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions