Opened 20 years ago

Closed 19 years ago

Last modified 18 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
Pull Requests:18733 merged, 18388 merged, 17781 merged, 18063 merged, 17793 merged, 18096 merged, 17843 merged, 17350 unmerged, 17331 merged, 17488 merged, 17490 merged, 17248 merged, 17288 merged, 17367 merged, 17313 merged, 17061 merged, 16887 merged, 16729 merged, 16611 unmerged, 16444 merged, 16274 merged, 16298 merged, 15383 merged, 13950 merged, 13947 unmerged, 13049 merged, 12117 unmerged, 12929 merged, 12048 merged, 10944 merged

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@…>, 20 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, 20 years ago

Component: Core frameworkDatabase wrapper

comment:3 by anonymous, 20 years ago

Component: Database wrapperCore framework

comment:4 by mrtact@…, 20 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, 19 years ago

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