CREATE TABLE tcg.public.TCG_MTG_Deck (
	  deck_id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY
    , name VARCHAR(250) NOT NULL
    , is_commander BOOLEAN NOT NULL DEFAULT TRUE
    , commander_bracket_id INT
    , CONSTRAINT FK_TCG_MTG_Deck_commander_bracket_id
        FOREIGN KEY (commander_bracket_id)
        REFERENCES tcg.public.TCG_MTG_Deck_Commander_Bracket(commander_bracket_id)
    , active BOOLEAN NOT NULL DEFAULT TRUE
	, created_on TIMESTAMP NOT NULL
	, created_by_user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Deck_created_by_user_id
        FOREIGN KEY (created_by_user_id)
        REFERENCES tcg.public.TCG_User(user_id)
	, updated_last_on TIMESTAMP NOT NULL
	, updated_last_by_user_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Deck_updated_last_by_user_id
        FOREIGN KEY (updated_last_by_user_id)
        REFERENCES tcg.public.TCG_User(user_id)
    , change_set_id INT NOT NULL
    , CONSTRAINT FK_TCG_MTG_Deck_change_set_id
		FOREIGN KEY (change_set_id)
        REFERENCES tcg.public.TCG_Change_Set(change_set_id)
);
