Comments (2)
Actually it should be just
- for hex:
sa.Column('id', sa.CHAR(32), nullable=False),
- for string:
sa.Column('id', sa.CHAR(36), nullable=False),
I changed the column repr method to return char.
It should not use ormar at all but unfortunately by default alembic uses full module name for autoganeration.
To change it you have to pass user_module_prefix='sa.'
parameter to context.configure
in alembic env.py.
The sa. is the default sqlalchemy prefix, that you can also configure it so if you change it to something different in alembic configuration (sqlalchemy_module_prefix
parameter) this one have to match.
"""
***Beginning of the sample revision file***
Revision ID: XXX
Revises:
Create Date: XXXX-XX-XX
"""
from alembic import op
# alembic by default imports sqlalchemy as sa
# this has to match the set prefix ('sa.' in example above)
import sqlalchemy as sa
So it should look like this:
(<===trimmed for clarity===>)
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
context.configure(
url=URL,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
# if you use UUID field set also this param
# the prefix has to match sqlalchemy import name in alembic
# that can be set by sqlalchemy_module_prefix option (default 'sa.')
user_module_prefix='sa.'
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = create_engine(URL)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
# if you use UUID field set also this param
# the prefix has to match sqlalchemy import name in alembic
# that can be set by sqlalchemy_module_prefix option (default 'sa.')
user_module_prefix='sa.'
)
with context.begin_transaction():
context.run_migrations()
(<===trimmed for clarity===>)
Please update to 0.5.5 for this feature - also included this in the alembic docs.
from ormar.
I see the problem now, thanks for the quick fix and instructions!
from ormar.
Related Issues (20)
- Multiple reverse relations not working.
- Add `first_or_none`
- FastpAPI state has not database HOT 4
- How to configure alembic autogenerate with multiple model files HOT 5
- Error awaiting None
- Upgrade to SQLAlchemy 2.0 HOT 5
- Add SELECT DISTINCT feature to queryset
- Failing test: test_weakref_init
- Reverse relation not returned from get_pydantic
- Low performance on select_all() call HOT 1
- Nullable ForeignKey field does not get updated to null
- The future of ORMAR HOT 6
- Support specifying a table comment
- Please support pydantic-2.x HOT 3
- New release with the latest dependency upgrades HOT 2
- Unresolved attribute reference 'objects'
- Model field types and pyright
- v0.20.0 is released as stable instead of beta HOT 3
- Allow tables without primary key
- Allow Pydantic 1.10.13 to mitigate security risk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ormar.