This is the alembic file for the buggy migration :
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('assessments', 'creation_date',
existing_type=mysql.DATETIME(),
nullable=False,
existing_server_default=sa.text('CURRENT_TIMESTAMP'))
op.create_foreign_key(None, 'assessments', 'users', ['creator_id'], ['identifier'])
This is the model :
from itertools import groupby
from operator import attrgetter
from pandas import read_excel
from sqlalchemy import Column
from sqlalchemy import Integer, Float, ForeignKey, String, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.sql.functions import current_timestamp
from werkzeug.datastructures import FileStorage
from linnote.core.user import Student
from linnote.core.utils.database import BASE
class Assessment(BASE):
"""Evaluation of students knowledge."""
__tablename__ = 'assessments'
identifier = Column(Integer, primary_key=True)
creator = relationship('User', uselist=False)
creation_date = Column(DateTime, nullable=False, server_default=current_timestamp())
title = Column(String(250), nullable=False, index=True)
coefficient = Column(Integer, nullable=False)
precision = Column(Integer, nullable=False, default=3)
results = relationship('Mark', cascade="all")
reports = relationship('Report', back_populates="assessment", cascade="all")
creator_id = Column(Integer, ForeignKey('users.identifier'))
And finally I'm stuck with that on PA : sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1067 (42000): Invalid default value for 'creation_date' [SQL: 'ALTER TABLE assessme nts MODIFY creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'] (Background on this error at: http://sqlalche.me/e/f405)
I've tried locally against a MySQL database and everything was working properly... Any idea why this is bugging ?