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
30.17k stars 3.82k forks source link

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

Open Dedej-Bergin opened 3 months ago

Dedej-Bergin commented 3 months 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 3 months 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",
        ))
    }