-
-
Notifications
You must be signed in to change notification settings - Fork 301
Description
I have a table (SQLite) with a column that looks like
created_at DATETIME DEFAULT (datetime('now', 'localtime')) NOT NULL,The parentheses around datetime('now', 'localtime') are syntactically necessary, without which one would get a syntax error:
The DEFAULT clause specifies a default value to use for the column if no value is explicitly provided by the user when doing an INSERT. If there is no explicit DEFAULT clause attached to a column definition, then the default value of the column is NULL. An explicit DEFAULT clause may specify that the default value is NULL, a string constant, a blob constant, a signed-number, or any constant expression enclosed in parentheses.
https://www.sqlite.org/lang_createtable.html (emphasis mine)
When I use op.batch_alter_table, the reflected column's server_default is a text clause datetime('now', 'localtime'), without parentheses, so when alembic attempts to create the new table it fails:
CREATE TABLE _alembic_tmp_foo (
...
created_at DATETIME DEFAULT datetime('now', 'localtime') NOT NULL, -- syntax error
)I'm new to SQLA and Alembic so please excuse me if the fault is on me.