I just migrated my dev environment from Ubuntu Linux to Mac OSX snow leopard. All of this was working on Linux. On both, I have used MySQL for Django's db.
Django's reset function is not issuing drop commands for all of my app's models. Here is my models.py (with the Forum and User object fields removed for brevity):
from django.db import models
class Forum(models.Model):
...
class User(models.Model):
...
class Message(models.Model):
date = models.DateTimeField()
content_file = models.CharField(max_length=48)
summary_file = models.CharField(max_length=48)
user = models.ForeignKey(User)
thread = models.ForeignKey('self', blank=True, null=True)
lft = models.IntegerField(default=1)
rgt = models.IntegerField(default=2)
def __unicode__(self):
return str(self.date) + '_' + unicode(self.user)
class Message_forum(models.Model):
message = models.ForeignKey(Message)
forum = models.ForeignKey(Forum)
status = models.IntegerField()
position = models.IntegerField(blank=True, null=True)
def __unicode__(self):
return unicode(self.message) + '_' + unicode(self.forum)
Here is the output of django's sql command:
BEGIN;
CREATE TABLE `AO_forum` (
...
)
;
CREATE TABLE `AO_user` (
...
)
;
CREATE TABLE `AO_message` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`date` datetime NOT NULL,
`content_file` varchar(48) NOT NULL,
`summary_file` varchar(48) NOT NULL,
`user_id` integer NOT NULL,
`thread_id` integer,
`lft` integer NOT NULL,
`rgt` integer NOT NULL
)
;
ALTER TABLE `AO_message` ADD CONSTRAINT `user_id_refs_id_12d253fe` FOREIGN KEY (`user_id`) REFERENCES `AO_user` (`id`);
ALTER TABLE `AO_message` ADD CONSTRAINT `thread_id_refs_id_12262c89` FOREIGN KEY (`thread_id`) REFERENCES `AO_message` (`id`);
CREATE TABLE `AO_message_forum` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`message_id` integer NOT NULL,
`forum_id` integer NOT NULL,
`status` integer NOT NULL,
`position` integer
)
;
ALTER TABLE `AO_message_forum` ADD CONSTRAINT `message_id_refs_id_68762267` FOREIGN KEY (`message_id`) REFERENCES `AO_message` (`id`);
ALTER TABLE `AO_message_forum` ADD CONSTRAINT `forum_id_refs_id_31073c3d` FOREIGN KEY (`forum_id`) REFERENCES `AO_forum` (`id`);
COMMIT;
And here is the output of django's sqlreset command:
BEGIN;
DROP TABLE `AO_user`;
DROP TABLE `AO_forum`;
CREATE TABLE `AO_forum` (
...
)
;
CREATE TABLE `AO_user` (
...
)
;
CREATE TABLE `AO_message` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`date` datetime NOT NULL,
`content_file` varchar(48) NOT NULL,
`summary_file` varchar(48) NOT NULL,
`user_id` integer NOT NULL,
`thread_id` integer,
`lft` integer NOT NULL,
`rgt` integer NOT NULL
)
;
ALTER TABLE `AO_message` ADD CONSTRAINT `user_id_refs_id_12d253fe` FOREIGN KEY (`user_id`) REFERENCES `AO_user` (`id`);
ALTER TABLE `AO_message` ADD CONSTRAINT `thread_id_refs_id_12262c89` FOREIGN KEY (`thread_id`) REFERENCES `AO_message` (`id`);
CREATE TABLE `AO_message_forum` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`message_id` integer NOT NULL,
`forum_id` integer NOT NULL,
`status` integer NOT NULL,
`position` integer
)
;
ALTER TABLE `AO_message_forum` ADD CONSTRAINT `message_id_refs_id_68762267` FOREIGN KEY (`message_id`) REFERENCES `AO_message` (`id`);
ALTER TABLE `AO_message_forum` ADD CONSTRAINT `forum_id_refs_id_31073c3d` FOREIGN KEY (`forum_id`) REFERENCES `AO_forum` (`id`);
CREATE INDEX `AO_message_user_id` ON `AO_message` (`user_id`);
CREATE INDEX `AO_message_thread_id` ON `AO_message` (`thread_id`);
CREATE INDEX `AO_message_forum_message_id` ON `AO_message_forum` (`message_id`);
CREATE INDEX `AO_message_forum_forum_id` ON `AO_message_forum` (`forum_id`);
COMMIT;
Only drop commands for Forum and User are generated. Also confusing and possibly related is that when the tables get created, my Django project name ("AO") is appended in all caps for the forum and user tables, but in lowercase for the message and message_forum tables (which are the ones without drop commands).