cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.96k stars 3.79k forks source link

ALTER TABLE ADD COLUMN add NOT NULL and UNIQUE constraints columns to DSC #128852

Open Dedej-Bergin opened 1 month ago

Dedej-Bergin commented 1 month ago

Is your feature request related to a problem? Please describe. This is one of the missing pieces to support ALTER TABLE ADD COLUMN fully in the declarative schema changer.

Describe the solution you'd like

Jira issue: CRDB-41235

Epic CRDB-31282

Dedej-Bergin commented 1 month ago

A starting point to look at could be here in scbuildstmt/alter_table_add_column

    // Unique without an index is unsupported.
    if d.Unique.WithoutIndex {
        // TODO(rytaft): add support for this in the future if we want to expose
        // UNIQUE WITHOUT INDEX to users.
        panic(errors.WithHint(
            pgerror.New(
                pgcode.FeatureNotSupported,
                "adding a column marked as UNIQUE WITHOUT INDEX is unsupported",
            ),
            "add the column first, then run ALTER TABLE ... ADD CONSTRAINT to add a "+
                "UNIQUE WITHOUT INDEX constraint on the column",
        ))
    }