Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#12 closed (fixed)

Add metasystem database-check functionality

Reported by: adrian Owned by: adrian
Component: Metasystem Version:
Severity: normal Keywords:
Cc: moof@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

We should automate the checking of whether everything is properly installed in the database for a particular app. For instance, a command such as django-admin.py dbcheck news would:

  • Check that the package exists in the DB.
  • Check that all the permissions exist in the DB.
  • Check that there aren't any *extra* permissions in the DB that the model doesn't know about.
  • Check that all the content types exist in the DB.
  • Check that there aren't any *extra* content types in the DB for this app.
  • Check that there aren't any missing fields.
  • Check that the fields are in the correct data type.

Change History (9)

comment:1 Changed 10 years ago by Moof <moof@…>

  • Cc moof@… added

One possible extentiosn of what you could do knowing this information is up over here: http://metamoof.net/blog/2005/07/26/well_i%27ll_be_django%27d

comment:2 Changed 10 years ago by anonymous

  • Component changed from Core framework to Database wrapper

comment:3 Changed 10 years ago by anonymous

  • Component changed from Database wrapper to Core framework

comment:4 Changed 10 years ago by mrtact@…

I have an even easier suggestion.

Add a table to the defaults created by django-admin init. Each row of the table corresponds to one model file. This table has two fields: hash and text. When an app is installed, take the full text of each model file and put it in the text field. Hash the text and put it in the hash field. When you run a db-check (which should be automatic at server startup, imho), simply hash each current model file and compare it to the hash stored in the db for that model file. If they differ, the model has changed.

At that point, fetch the full text of the model file from the db and diff it against current. It should be fairly easy to tie lines that differ to particular data structure. This provides you with a comprehensive set of what has changed.

  • Tim Keating

comment:5 Changed 10 years ago by Brendan O'Connor <brenocon@…>

Excellent idea! After doing the diff, the next step would be to generate ALTER TABLE statements if possible (if the schemas aren't very different...)

comment:6 Changed 10 years ago by brantley (deadwisdom@…

I have created a way to update your database dependant on an updated model. I created a django-developers posting that goes into greater detail.

comment:7 Changed 10 years ago by adrian

  • Component changed from Core framework to Metasystem

comment:8 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

The new syncdb command accomplishes this. (Minus the database-schema changes, of course, but that's another ticket.)

comment:9 Changed 9 years ago by URL

  • Type enhancement deleted
Note: See TracTickets for help on using tickets.
Back to Top