Open FIRDOUS-BHAT opened 3 years ago
Need more info
Here is an example model,
class Course(Model): """ This references course of each competative exams """ id = fields.UUIDField(pk=True) name = fields.CharField(max_length=100, unique=True) slug = fields.CharField(max_length=250, unique=True) icon_image = fields.TextField() web_icon = fields.TextField(null=True, blank=True) is_active = fields.BooleanField(default=True) updated_at = fields.DatetimeField(null=True, blank=True) created_at = fields.DatetimeField(auto_now_add=True) preference = fields.ForeignKeyField( "models.Preference", related_name="courses", on_delete='CASCADE', )
While executing `aerich migrate`, it will have all the columns into the sql file but on executing `aerich migrate` it sometimes doesn't migrate some of the columns into the database.
I'm using postgres database.
@long2ice this issue still presists. Mentioning here one of the examples that I faced,
-- upgrade -- CREATE TABLE IF NOT EXISTS "bookmarkedvideos" ( "id" UUID NOT NULL PRIMARY KEY, "created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, "student_id" UUID NOT NULL REFERENCES "student" ("id") ON DELETE CASCADE, "video_id" UUID NOT NULL REFERENCES "coursecategorylectures" ("id") ON DELETE CASCADE ); -- downgrade -- DROP TABLE IF EXISTS "bookmarkedvideos";
After aerich upgrade
, I ran the create query but got this error,
tortoise.exceptions.OperationalError: column "created_at" of relation "bookmarkedvideos" does not exist
There is an issue with the aerich migration that I observed is while executing
aerich migrate
all columns of a table do reflect in migration file but after executingaerich upgrade
one or the other misses from database table.Note: This issue arises sometimes only.