--- ticket-category-and-tags-table
IF NOT EXISTS (
    SELECT * FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_NAME = 'tickets_to_categories' AND TABLE_TYPE = 'BASE TABLE'
)
BEGIN
    CREATE TABLE tickets_to_categories (
        ticket_id BIGINT NOT NULL,
        category_id BIGINT NOT NULL,
        PRIMARY KEY (ticket_id, category_id)
    )
END

IF NOT EXISTS (
    SELECT * FROM INFORMATION_SCHEMA.TABLES 
    WHERE TABLE_NAME = 'tickets_to_tags' AND TABLE_TYPE = 'BASE TABLE'
)
BEGIN
    CREATE TABLE tickets_to_tags (
        ticket_id BIGINT NOT NULL,
        tag_id BIGINT NOT NULL,
        PRIMARY KEY (ticket_id, tag_id)
    )
END
