Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#12 closed (fixed)

Add metasystem database-check functionality

Reported by: Adrian Holovaty Owned by: Adrian Holovaty
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: no UI/UX: no

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 by Moof <moof@…>, 19 years ago

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 by anonymous, 19 years ago

Component: Core frameworkDatabase wrapper

comment:3 by anonymous, 19 years ago

Component: Database wrapperCore framework

comment:4 by mrtact@…, 19 years ago

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 by Brendan O'Connor <brenocon@…>, 19 years ago

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 by brantley (deadwisdom@…, 19 years ago

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 by Adrian Holovaty, 19 years ago

Component: Core frameworkMetasystem

comment:8 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

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

comment:9 by URL, 18 years ago

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