environment: Postgres
when I using “dbt run” to the table,
dbt will delete old table (I already dbt run before and alter PK).
Is there any way to indicate PK in models?
The context of why I’m trying to do this
I using airbyte to sync db table, when data sync it will run dbt and remove old table then create new one.
Another idea would be to add the needed alter table XXXXX add primary key... statement as a post-hook to your model. Then it’d get executed with every dbt run.
Otherwise, you can indicate the functionality of a PK in the yml by adding unique/not null tests (or dbt_expectationsexpect_compound_columns_to_be_unique for a multi column PK)