Opened 16 years ago

Closed 16 years ago

#8349 closed (wontfix)

syncdb doesn't make all the necessary changes with the Oracle backend

Reported by: guneeyoufix Owned by: nobody
Component: Core (Management commands) Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm using the Oracle backend, with an already existing database. I had to make changes to the output of the inspectdb command so that my models.py and the actual database matched.

However, no matter how often I issue the syncdb command, some sequences and triggers won't be created (basically all of the triggers that are directly related to my application).

I have attached the output of the sqlall command for the concerned app.

Attachments (1)

sqlall.sql (5.3 KB ) - added by guneeyoufix 16 years ago.
Output of the sqlall command for the application

Download all attachments as: .zip

Change History (4)

by guneeyoufix, 16 years ago

Attachment: sqlall.sql added

Output of the sqlall command for the application

comment:1 by Malcolm Tredinnick, 16 years ago

It's not clear what the problem is here. If you're running "inspectdb" to create the models to match the existing database, what are you hoping that "syncdb" will do? Why are you running it?

comment:2 by guneeyoufix, 16 years ago

Let's try to explain the problem here.

With oracle, you don't directly have the concept of auto incrementing field, like you have in MySQL.
To get this functionality with Oracle, you have to create a sequence, and a trigger that returns the next index in the sequence when inserting a new row. And that's how django handles the autofield.

However, you can also use the .NEXTVAL attribute of a sequence to get this number (which is actually what you do in the trigger) in the place of the autofield.
Here is an example : INSERT INTO TABLE(PK, OTHER_STUFF) VALUES (PK_SEQUENCE.NEXTVAL, 'STUFF');
This is actually how I handle my primary keys outside the django framework.

Not being able to use this technique from the django framework, I modified the output of the inspectdb command so that these columns are filled automatically.

After the modifications, I ran syncdb so that all the necessary oracle objects are created. But the triggers and sequences that should be created (because they don't already exist in the database) are not created. And I believe the role of syncdb is precisely to create all necessary objects that are don't already exist.

Hence this ticket.
Hope it's clear now what my problem is...

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

You are hoping for behaviour from syncdb that doesn't exist. At the moment, despite the name, it only does the SQL work for applications that don't already exist. Detecting modifications or missing pieces of existing applications is beyond the scope. You probably should look at one of the various schema evolution projects around (e.g. django-evolution or south) and submit a patch to them.

One day schema-evolution, which includes things like adding missing/changed triggers and indexes will probably be part of Django's core. Right now, this is out of scope and in the same basket as all other schema-evolution requests.

Note: See TracTickets for help on using tickets.
Back to Top