I want to create a new column. How do I write this in SQL?
class mytable(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
I want to create a new column. How do I write this in SQL?
class mytable(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
ALTER TABLE mytable
ADD created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
If you don't want to use South to manage this automatically - which is highly recommended, by the way - you can easily see what SQL you need by running ./manage.py sqlall <appname>
. This will show you all the SQL to create the models in your app, so you can find the definition of your new field there.