It seems like default value on columns is only on the ORM layer, and is not actually setting a default value in the DB. At the same time, the ID key for example has a default modifier in the database, which tells me it is possible to do that, but not sure how?
Example code:
class Host(models.Model):
name = models.CharField(max_length=255, null=False)
created_at = models.DateTimeField(default=datetime.now, blank=True)
creates the following table:
Column | Type | Modifiers
------------+--------------------------+-------------------------------------------------------------
id | integer | not null default nextval('myapp_host_id_seq'::regclass)
name | character varying(255) | not null
created_at | timestamp with time zone | not null
Is there a way to have the migration set default current_timestamp in the created_at modifiers? If not, is there a way to pass in raw SQL migrations? I need it because the database is used by other processes (e.g. batch processes) which I don't want to have to enforce things like default values on the application layer.
models.Migrationand have it run raw sql.