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

854 questions
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
  • 967
  • 2
  • 16
  • 28
-1
votes
2 answers

How to add a new column to an existing database table with unique and not null constraint

I have a users table, with the primary key being an id field, which is an autoincrementing integer. I don't have a username field right now, but I would like to add one. Now, the username should be UNIQUE and NOT NULL so that I can query the…
berinaniesh
  • 198
  • 13
-1
votes
1 answer

Flask & Alembic: how to migrate models to postgresql

I'm doing a technical test for an interview I'm doing. It's a flask application running in docker with PostgreSQL and already using SqlAlchemy. Unfortunately I don't have knowledge in flask, only Django. I have added a new Model to my app and I need…
BoumTAC
  • 3,531
  • 6
  • 32
  • 44
-1
votes
1 answer

sqlite3.OperationalError: duplicate column name: operator

I have been following the book of Paul Crickard - "Data Engineering with python". I wanted to install and configure Apache Airflow. After installing it, I tried to initialize the database with airflow db init It raised the following…
-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
  • 2,345
  • 1
  • 14
  • 29
-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,…
Amaimersion
  • 787
  • 15
  • 28
-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
  • 1,181
  • 1
  • 14
  • 29
-1
votes
1 answer

Flask- Migrate not recognizing models

I'm trying to extend the flask-base project https://github.com/hack4impact/flask-base/tree/master/app which comes with a user model only. I've added to the project so that the dev database looks like the screenshot above. My model folder is made…
user1592380
  • 34,265
  • 92
  • 284
  • 515
-1
votes
1 answer

Alembic database migration on development environment works -- how to apply to production?

My Alembic database migration is working in my dev environment using sqlAlchemy. How do I apply this to my production environment?
TaiwanGrapefruitTea
  • 1,045
  • 2
  • 14
  • 25
-2
votes
0 answers

what is the proper way to update my alembic migrations. as i take pull from main and i have different alembic head but my localdb is still pointing

whatsa the correct way to update my localdb with main.I take pull from main so my main has uptodate head version but my localdb is still poinitng to different version_num that i updated while creating my lcoal migrations.so when i run alembc upgrade…
Ramm
  • 1
-2
votes
1 answer

Alembic MSSQL Unique Constraint Allow Nulls

Problem to Solve Using MSSQL I'd like to have a column that is unique and accepts nulls. Issues Add two rows of data into a column that allows nulls with the unique constraint like in the implementation below gives the following error: Violation of…
Daniel Butler
  • 3,239
  • 2
  • 24
  • 37
-2
votes
1 answer

Alembic migration shows error in mssql in windows server. How do i solve this?

I tried to extract json object from a column in migration. I get this error __main__ ERROR (pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '>' Here is my code. how do i solve…
-2
votes
1 answer

Is it possible to let users create and perform database migrations from a form?

Can you take form data and change database schema? Is it a good idea? Is there a downside to many migrations from a 'default' database? I want users to be able to add / remove tables, columns, and rows. Making schema changes requires migrations,…
xGlorify
  • 119
  • 1
  • 12
-3
votes
3 answers

Postgres refuses to find existing table, why?

I have a Postgres database and following tables inside of it, created using python Alembic ORM. Everything looks great at the first moment, but when trying to access any of the given tables, it throws: Did not find any relation named. …
CraZyCoDer
  • 367
  • 1
  • 2
  • 16
1 2 3
56
57