django-redshift-backend icon indicating copy to clipboard operation
django-redshift-backend copied to clipboard

Autofield Model Field Generates Duplicate Identity Specification in Migration Statement

Open thefyk opened this issue 2 years ago • 2 comments

"id" integer identity(1, 1) NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY

Problem

  • When running migrations using django-redshift-backend, columns of type AutoField have identity specified twice, resulting in the following error: "multiple default values specified for column "id" of table "table" [ErrorId: 1-63742d45-7a28d2c01ec6ac8032477b89]"

Procedure to reproduce the problem

Create a model without a primary key field. Run makemigrations followed by migrate.

Expected results

The migration will not run due to the duplicate Identity reference. I suggest changing

redshift_data_types = {
    "AutoField": "integer identity(1, 1)",
    "BigAutoField": "bigint identity(1, 1)",
    "TextField": "varchar(max)",  # text must be varchar(max)
    "UUIDField": "varchar(32)",  # redshift doesn't support uuid fields
}

to

redshift_data_types = {
    "AutoField": "integer",
    "BigAutoField": "bigint",
    "TextField": "varchar(max)",  # text must be varchar(max)
    "UUIDField": "varchar(32)",  # redshift doesn't support uuid fields
}

thefyk avatar Nov 16 '22 00:11 thefyk

Thanks. I'm a little stuck on a task right now, so I'll take a look little later.

shimizukawa avatar Nov 16 '22 00:11 shimizukawa

Hello, I'm running into the same issue as @thefyk, when trying to migrate to redshift. Any updates?

ldderrick avatar Mar 02 '23 21:03 ldderrick

This problem has been resolved by #129. This problem occurred when using django-redshift-backend with Django 4.1 or later.

After checking the issues that need to be addressed, we plan to release it as version 4.0.0.

shimizukawa avatar Jul 22 '24 21:07 shimizukawa

Now django-redshift-backend 4.0.0 has been released.

shimizukawa avatar Jul 23 '24 19:07 shimizukawa