I changed the tutorial on the SqlAlchemy-Migrate tutorial into the declarative syntax of my Pylons Pyramid project. I can successfully upgrade and downgrade, but the Base.metadata.drop_all (migrate_engine) command Base.metadata.drop_all bothers me. Here is my migration file:
from sqlalchemy import Column from sqlalchemy.types import Integer, String, DateTime from sqlalchemy.sql import func from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker from zope.sqlalchemy import ZopeTransactionExtension DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) Base = declarative_base() class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) email = Column(String(75), unique=True) fullname = Column(String(60)) password = Column(String(51)) last_login = Column(DateTime) date_joined = Column(DateTime, default=func.now()) def upgrade(migrate_engine):
[edit] My question was how to create tables individually. I did not know that this is my question until you ask the wrong question to solve the right question.
source share