Skip to content

Weasel is generating invalid migration SQL #593

Description

@jovball

I'm running db-patch with WolverineFx 6.35 and Weasel.SqlServer 9.30. The generated SQL needs to have GO before the CREATE OR ALTER PROCEDURE statement. I have indicated that location in the generated script below. I'll also add that it would be nice if these scripts were idempotent.

IF NOT EXISTS ( SELECT  *
                FROM    sys.schemas
                WHERE   name = N'wolverine' )
    EXEC('CREATE SCHEMA [wolverine]');


CREATE INDEX idx_wolverine_outgoing_envelopes_recover ON wolverine.wolverine_outgoing_envelopes (destination) WHERE ([owner_id]=0);
CREATE INDEX idx_wolverine_incoming_envelopes_recover ON wolverine.wolverine_incoming_envelopes (received_at) WHERE ([status]='Incoming' AND [owner_id]=0);
CREATE INDEX idx_wolverine_incoming_envelopes_keep_until ON wolverine.wolverine_incoming_envelopes (keep_until) WHERE ([status]='Handled');
CREATE INDEX idx_wolverine_incoming_envelopes_scheduled ON wolverine.wolverine_incoming_envelopes 
(execution_time) WHERE ([status]='Scheduled');
-- NEEDS A GO STATEMENT HERE
CREATE OR ALTER PROCEDURE wolverine.uspMarkIncomingOwnership
    @IDLIST wolverine.EnvelopeIdList READONLY,
    @owner INT
AS

-- GH-4216: without the status predicate this also rewrites rows that are already Incoming or Handled.
-- The load side of the poll selects only Scheduled rows, so constraining the update to match costs nothing
-- and keeps the promotion from touching a row it never selected.
UPDATE wolverine.wolverine_incoming_envelopes
SET owner_id = @owner, status = 'Incoming'
WHERE status = 'Scheduled' AND id IN (SELECT ID FROM @IDLIST);

alter table wolverine.wolverine_nodes alter column version varchar(500) NULL;
alter table wolverine.wolverine_control_queue alter column message_type varchar(500) NOT NULL;
alter table wolverine.wolverine_agent_restrictions alter column uri varchar(500) NOT NULL;
alter table wolverine.wolverine_agent_restrictions alter column type varchar(500) NOT NULL;
alter table wolverine.wolverine_node_records alter column description varchar(1000) NULL;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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