Questions tagged [alembic]

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Some of the important operations that can be performed with alembic are

  • Upgrade(Perform Database migrations, Example: create/alter/modify)
  • Downgrade(Its the reverse operation of upgrade to undo the upgrade changes)
  • Current(Show the current revision and state of migration in the database)
  • Init(Initialize a new scripts directory)
  • Revision(Create a new revision file)

Related tags

References

621 questions
0
votes
1 answer

Flask & SqlAlchemy - alembic session.add_all() results in AttributeError: 'bool' object has no attribute 'clear' error

I'm trying to insert some data as part of deployment. I've created following alembic revision script revision = '59891ffc8502' down_revision = '349540cf9cef' from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql from…
Arek S
  • 2,913
  • 4
  • 19
  • 29
0
votes
1 answer

flask-migrate wants to drop my indeces

I've got a Flask app with the following models: class User(db.Model, UserMixin): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(64), unique=True, index=True) password_hash =…
treznick
  • 25
  • 2
0
votes
1 answer

AttributeError: 'int' object has no attribute '_compiler_dispatch'

I am using the flask-sqlalchemy extension with alembic for migrations. When I try to add a new migration file and upgrade the schema to the latest one, I get the following error: AttributeError: 'int' object has no attribute…
Kevin
  • 5,891
  • 5
  • 36
  • 52
0
votes
1 answer

Flask migration error

I've got an application build on flask and I wanted to create a new migration for it today. When I run $python manage.py db upgrade i got the message raise util.CommandError('Only a single head is supported. The…
shanky
  • 590
  • 12
  • 40
0
votes
2 answers

Alembic not able to import flask application ORM models

Use case: I'm attempting to create a migration script that will create a table (which will make a many to many relationship) and then populate that table with foreign keys from the database. To do this I'm attempting to load my flask applications…
AlexLordThorsen
  • 6,777
  • 2
  • 39
  • 82
0
votes
1 answer

Alembic/Flask-migrate doesn't recognise database structure

I have a Flask-based application and I'm trying to enable migrations to be able to manage database structural changes. My database is not empty and contains tables and records before I started with alembic and flask-migrate. First, I tried to use…
lawicko
  • 6,966
  • 2
  • 34
  • 47
0
votes
1 answer

Alembic / Flask-migrate migration on Heroku runs but does not create tables

I am attempting to deploy a Flask app to Heroku. I have pushed to Heroku and can access my login page but any call to the db gives an OperationalError: 2014-01-29T12:12:31.801772+00:00 app[web.1]: OperationalError: (OperationalError) no such table:…
kendlete
  • 214
  • 3
  • 12
0
votes
1 answer

alembic will allow sql files under versions?

In sqlalchemy-migrate repos, we can place .sql files instead of .py files under versions folder for upgrading/downgrading database schema. 001_mysql_downgrade.sql 001_mysql_upgrade.sql Is the same feature exist in alembic? If yes can someone plz…
Murali Mopuru
  • 4,602
  • 5
  • 26
  • 45
0
votes
1 answer

Alembic Migrations for Flask

I have been trying to get the Alembic migration system configured for my Flask app for the past 7 hours with no success. Any ideas as to what I am doing wrong? I have tried all the solutions I found here, but they did not seem to work for me. I get…
GangstaGraham
  • 7,425
  • 11
  • 39
  • 54
0
votes
1 answer

How do I set an initial value for a primary key set to automatically increment using SQLAlchemy/Alembic?

In MySQL, we can use AUTO_INCREMENT = ? to automatically insert a primary key value. How do we do it in SQLAlchemy/Alembic? Thanks very much!
user1342336
  • 877
  • 2
  • 16
  • 27
-1
votes
1 answer

How to migrate SQLAlchemy database without generating migration script

I am using Flask and SQLAlchemy in a serverless function, which I don't have access to the command line. And there are times that I want to change the tables. Basically I want to automatically create new tables (already done by create_all) and…
Allan Chain
  • 683
  • 6
  • 19
-1
votes
1 answer

After upgrade, how to fill new table with values that based on existing values of another table?

I have this table with some data in it: Name: users Columns: id (primary key) | name Rows: 1) 1 | "name 1" 2) 2 | "name 2" 3) 3 | "name 3" Relationships: settings I need to create this table: Name: user_settings Columns: user_id (primary_key,…
Immersion
  • 409
  • 6
  • 16
-1
votes
1 answer

Python TypeError: option values must be strings in Migrator

Migrator Error Traceback (most recent call last): File > "/home/arjdu-d-1890/PycharmProjects/git-local-repo/example-flask-crud/venv/bin/flask", > line 8, in > sys.exit(main()) File…
-1
votes
1 answer

Which parts of a SQLAlchemy Table definition are used only for migrations (Alembic) vs. instance manipulation?

I'm working with a database where we have elected to manage the schema with external tools and are moving away from python for schema management. Our SQLALchemy ORM models have stuck around though of course and I'm now wondering if much of the…
medley56
  • 865
  • 8
  • 23
-1
votes
1 answer

Flask - change the column type in existing database

I have following Model in existing db: class Advert(db.Model): id = db.Column(db.Integer, primary_key=True) date = db.Column(db.DateTime, nullable=False, default = datetime.utcnow) title = db.Column(db.String(100), nullable=False) …
cheng
  • 1
  • 2
1 2 3
41
42