-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ProgrammingError
when unapplying migrations
#179
Comments
Thanks for reporting, definitely seems like a bug on pgtrigger's end. I will mark it as such and keep this open. Are you able to currently work around this? The unfortunate hack right now may simply be manually removing the statement inserted into the initial migration file that installs the trigger. I know that I've been able to successfully revert migrations in the past that drop tables with triggers, but I remember django doing some unexpected things with the ordering of some of these operations if they are in the same migration file. Can you confirm that you have the creation of the model and the addition of a trigger in the same migration file? If so, can you try marking Will see if I can reproduce this myself |
The
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Group',
fields=[
...
],
bases=(..., models.Model),
),
]
class Migration(migrations.Migration):
initial = True
dependencies = [
('groups', '0001_initial'),
...
]
operations are:
migrations.AddField(...),
migrations.AddField(...),
migrations.AddField(...),
migrations.AddConstraint(...),
migrations.AddConstraint(...),
pgtrigger.migrations.AddTrigger(
model_name='group',
trigger=pgtrigger.compiler.Trigger(name='RO_Group', sql=pgtrigger.compiler.UpsertTriggerSql(condition='WHEN (OLD."feide_id" IS DISTINCT FROM (NEW."feide_id") OR OLD."id" IS DISTINCT FROM (NEW."id") OR OLD."owner_id" IS DISTINCT FROM (NEW."owner_id"))', func="RAISE EXCEPTION 'pgtrigger: Cannot update rows from % table', TG_TABLE_NAME;", hash='130432f1fd9dcd2b84df3d5a24b09232b3276253', operation='UPDATE', pgid='pgtrigger_ro_group_deb1a', table='groups_group', when='BEFORE')),
),
] Adding I have not found a solution other than removing the trigger from the model's |
I am encountering a
ProgrammingError
when unapplying migrations that include triggers. The error occurs when running thepython manage.py migrate [app] zero
command or unapplying specific migrations. The issue seems to be related to the pgtrigger library attempting to install triggers on tables that have already been dropped.Here is an excerpt from one of the migration files generated by Django and
django-pgtrigger
:Here is relevant parts of the
Group
model:Here is the traceback of the error:
This may be related to #29, but I'm not sure.
The text was updated successfully, but these errors were encountered: