/*
 Migrates the Airlock IAM DB schema from version 7.6 to version 7.7.
 Written for MSSQL.
 */

CREATE TABLE flow_continuation_token
(
    pk                    BIGINT                                            NOT NULL IDENTITY (1, 1),
    token_hash            NVARCHAR(86) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
    user_id               NVARCHAR(100) COLLATE Latin1_General_CI_AI        NOT NULL,
    target_flow_id        NVARCHAR(30) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
    created_at            BIGINT                                            NOT NULL,
    valid_until           BIGINT                                            NOT NULL,
    configuration_context NVARCHAR(50) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,
    forward_url           NVARCHAR(200) COLLATE Latin1_General_CI_AI,
    tenant_id             NVARCHAR(50) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL,

    CONSTRAINT pk_flow_continuation_token PRIMARY KEY (pk)
);
-- Additional indexes
CREATE UNIQUE INDEX ux_flow_continuation_token ON flow_continuation_token (token_hash);
