]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/log
thirdparty/sqlalchemy/alembic.git
9 months agoedits
Mike Bayer [Tue, 8 Jul 2025 18:56:11 +0000 (14:56 -0400)] 
edits

Change-Id: Id490125a9ff4e23ba45b48ae89a55044a20f27f5

9 months agoMerge "Fixed missing prefix on FetchedValue" into main
Michael Bayer [Tue, 8 Jul 2025 18:44:16 +0000 (18:44 +0000)] 
Merge "Fixed missing prefix on FetchedValue" into main

9 months agoAdd "module" post-write hook
Frazer McLean [Tue, 8 Jul 2025 15:01:43 +0000 (11:01 -0400)] 
Add "module" post-write hook

This hook type is almost identical to the console_scripts hook, except
it's running `python -m black` instead of using black's console_script.

It is mainly useful for tools without console scripts (e.g. ruff), but
has semantics closer to the console_scripts hook in that it finds the
ruff module available to the running interpreter instead of finding
an executable by path.

Pull request courtesy Frazer McLean.

Fixes: #1686
Closes: #1687
Pull-request: https://github.com/sqlalchemy/alembic/pull/1687
Pull-request-sha: 54d29c34642d88e88ab29e46fa4022d227f8aa60
Change-Id: I804a1a7d3f6423ba23bc556b7f4024c401a8787e

9 months agoFixed missing prefix on FetchedValue
david-fed [Mon, 7 Jul 2025 20:44:15 +0000 (16:44 -0400)] 
Fixed missing prefix on FetchedValue

Fixed the rendering of ``server_default=FetchedValue()`` to ensure it is
preceded by the ``sa.`` prefix in the migration script. Pull request
courtesy david-fed.

Fixes: #1633
Closes: #1691
Pull-request: https://github.com/sqlalchemy/alembic/pull/1691
Pull-request-sha: 468ad598c7975d240c3b9911585b3367f32900af
Change-Id: I828655e26c5e6d2a39d5407dbcc20bda19d11a7a

9 months agofix metadata requirement in fk render; remove column.copy()
Mike Bayer [Tue, 8 Jul 2025 14:05:56 +0000 (10:05 -0400)] 
fix metadata requirement in fk render; remove column.copy()

Fixed autogenerate rendering bug which failed to render foreign key
constraints local to a :class:`.CreateTableOp` object if it did not refer
to a ``MetaData`` collection via a private constructor argument that would
not ordinarily be passed in user-defined rewriter recipes, including ones
in the Alembic cookbook section of the docs.

Also removed the use of column.copy() from the CreateTableOp rewriter
recipe and added a new test for this recipe which includes a table with
an FK.  it's not clear why copy() was needed here and if we get more
reports of issues, we can add to this test suite and adjust.

Fixes: #1692
Change-Id: I6cf6c8f62b7eb116cfc78216b3dbcbddad499691

9 months agoAdd pyproject async template to Alembic
Alc-Alc [Fri, 20 Jun 2025 12:56:37 +0000 (08:56 -0400)] 
Add pyproject async template to Alembic

Added new ``pyproject_async`` template, combining the new ``pyproject``
template with the ``async`` template.  Pull request courtesy Alc-Alc.

Closes: #1683
Pull-request: https://github.com/sqlalchemy/alembic/pull/1683
Pull-request-sha: 46d03fbff27f9569545854ba9e6ad388892adcfd

Change-Id: I4071e069154541bdb1af864982e553bee687222e

9 months agotry flake8-import-order 0.19.2
Mike Bayer [Tue, 24 Jun 2025 18:04:56 +0000 (14:04 -0400)] 
try flake8-import-order 0.19.2

the big new thang is that it is doing import order checks inside of
TYPE_CHECKING blocks.   Introduces some new codes that we
enthusiastically add to our ignore list.

Change-Id: I4e844408a8b218f9b92c43ad5e2a5c16781100be

9 months agodemo mysql alter for collate/charset
Mike Bayer [Thu, 19 Jun 2025 01:47:18 +0000 (21:47 -0400)] 
demo mysql alter for collate/charset

Change-Id: I80cf0ccea6023c1e3411eaf6eeec7b2e5acb73e5

9 months agoVersion 1.16.3 placeholder
Mike Bayer [Mon, 16 Jun 2025 18:05:24 +0000 (14:05 -0400)] 
Version 1.16.3 placeholder

9 months ago- 1.16.2 rel_1_16_2
Mike Bayer [Mon, 16 Jun 2025 18:03:04 +0000 (14:03 -0400)] 
- 1.16.2

9 months agochangelog edits
Mike Bayer [Mon, 16 Jun 2025 18:02:26 +0000 (14:02 -0400)] 
changelog edits

Change-Id: I5bd111c1a2110bb6c386d40295836aae87922c32

9 months agosupport 'append_delimiter' to fix #1679
jonathan vanasco [Mon, 16 Jun 2025 15:36:20 +0000 (11:36 -0400)] 
support 'append_delimiter' to fix #1679

Fixed rendering of ``pyproject.toml`` to include two newlines when
appending content to an existing file.  Pull request courtesy Jonathan
Vanasco.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #1679
Closes: #1680
Pull-request: https://github.com/sqlalchemy/alembic/pull/1680
Pull-request-sha: 20b2aca0d2f6a8f5957063b950e45874343e9a99

Change-Id: Ic2e76a3f791dbda0bd61f09a2c7bafbcdab5eb7f

9 months agoblock flake8-import-order 0.19.0
Mike Bayer [Mon, 16 Jun 2025 16:43:01 +0000 (12:43 -0400)] 
block flake8-import-order 0.19.0

It looks like their attempt to fix [1] has backfired in [2]

[1] https://github.com/PyCQA/flake8-import-order/issues/201
[2] https://github.com/PyCQA/flake8-import-order/issues/212

Change-Id: I755450a0b17215fe1e04a12e4d966d672b637b76

9 months agoMerge "[Fixes #1671] Passthrough `dialect_kwargs` to `ops.create_foreign_key()`"...
Michael Bayer [Mon, 16 Jun 2025 16:19:50 +0000 (16:19 +0000)] 
Merge "[Fixes #1671] Passthrough `dialect_kwargs` to `ops.create_foreign_key()`" into main

9 months agofix: remove double quotation marks in logs (#1682)
Tom Stein [Thu, 12 Jun 2025 20:07:07 +0000 (22:07 +0200)] 
fix: remove double quotation marks in logs (#1682)

- the '%r' caused two single ticks like '' to show
- What we want is a single tick '
- This aligns now with the usage in other log statements

9 months ago[Fixes #1671] Passthrough `dialect_kwargs` to `ops.create_foreign_key()`
Justin Malin [Thu, 12 Jun 2025 19:56:36 +0000 (15:56 -0400)] 
[Fixes #1671] Passthrough `dialect_kwargs` to `ops.create_foreign_key()`

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
Fixes #1671

SqlAlchemy supports adding dialect kwargs for foreign keys, as does `op.create_foreign_key()`, but the renderer for `ops.CreateForeignKeyOp` does not pass through `dialect_kwargs`. An example of this is `postgresql_not_valid`.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #1672
Pull-request: https://github.com/sqlalchemy/alembic/pull/1672
Pull-request-sha: 246a363617b1a4a5885d2fed32e82f3312b386ef

Change-Id: I5dabbc4dc408c13883a6225733d7c38f8daeee38

10 months agoupdates for mypy 1.16
Mike Bayer [Sun, 8 Jun 2025 20:14:19 +0000 (16:14 -0400)] 
updates for mypy 1.16

some errors go away, others come in.   basically moving
ignores around.  need to pin to 1.16 at the lowest as these
would now fail on earlier mypy versions

Change-Id: Ia46084c69f1496ad77e215aab3fe1e6104361a96

10 months agodocument toml_file argument
Mike Bayer [Sun, 8 Jun 2025 19:29:16 +0000 (15:29 -0400)] 
document toml_file argument

Change-Id: I3edf7f32d818ffa4f6cf08d15a2d1e4f20137ff2

10 months agoallow tuple type in down_revision in migration templates
Simon Tas [Thu, 29 May 2025 00:11:58 +0000 (20:11 -0400)] 
allow tuple type in down_revision in migration templates

<!-- Provide a general summary of your proposed changes in the Title field above -->

FIXES #1665

Currently the type of `down_revision` in migration templates is `Union[str, None]`. However, when you generate a migration using `alembic merge heads` it will generate a migration with a tuple of strings in `down_revision` which causes a type error.

### Description

f.e. when you have 2 heads and run `alembic merge heads` you will get a migration that looks like this:

```py
revision: str = "6cee9e23ed4b"
down_revision: Union[str, None] = ("aba1172f1a9f", "cdd5e67db84f")
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
```

which will give a type error with type checkers like mypy and pyright. This change fixes this. From the code it seems like just like `branch_labels` and `depends_on` the `down_revision` is first casted to a tuple if needed so typing it as `Sequence[str]` and not `Tuple[str, ...]` should be safe.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #1666
Pull-request: https://github.com/sqlalchemy/alembic/pull/1666
Pull-request-sha: 186df96240a621ba71247a4f5cbd6413e3bfc270

Change-Id: I7b203b85bf69f215871995e4c4f5b96c20528c7d

10 months agofix typo in tutoral.rst
Federico Caselli [Fri, 23 May 2025 18:24:14 +0000 (20:24 +0200)] 
fix typo in tutoral.rst

Change-Id: I59be2e4c8d977d4e4c0138d57d01615781c153eb

10 months agoadd detailed information on escaping percent signs in config files
Mike Bayer [Fri, 23 May 2025 15:54:12 +0000 (11:54 -0400)] 
add detailed information on escaping percent signs in config files

References: https://github.com/sqlalchemy/alembic/discussions/1662
Change-Id: I8ab42a8154976adda1a21d7eda008605a482fda2

10 months agoVersion 1.16.2 placeholder
Mike Bayer [Wed, 21 May 2025 23:11:23 +0000 (19:11 -0400)] 
Version 1.16.2 placeholder

10 months ago- 1.16.1 rel_1_16_1
Mike Bayer [Wed, 21 May 2025 23:10:03 +0000 (19:10 -0400)] 
- 1.16.1

10 months agoMerge "honor get_templates_path() first" into main
Michael Bayer [Wed, 21 May 2025 22:08:12 +0000 (22:08 +0000)] 
Merge "honor get_templates_path() first" into main

10 months agohonor get_templates_path() first
Mike Bayer [Wed, 21 May 2025 21:14:37 +0000 (17:14 -0400)] 
honor get_templates_path() first

Fixed regression caused by the ``pathlib`` refactoring that removed the use
of :meth:`.Config.get_template_directory` as the canonical source of
templates; the method is still present however it no longer would be
consulted for a custom config subclass, as was the case with flask-migrate.

Fixed regression caused by the ``pathlib`` refactoring where the "missing
template" error message failed to render the name of the template that
could not be found.

Fixes: #1659
Fixes: #1660
Change-Id: I1244f19c9f288eb52c8e9ffcc3835824d6b74bb6

10 months agoadd missing f-string
Federico Caselli [Wed, 21 May 2025 20:54:06 +0000 (22:54 +0200)] 
add missing f-string

Fixes: #1659
Change-Id: Ic6d59b95017088c4e3d8cf5e5a2a75448057c5fb

10 months agoVersion 1.16.1 placeholder
Mike Bayer [Wed, 21 May 2025 19:19:04 +0000 (15:19 -0400)] 
Version 1.16.1 placeholder

10 months ago- 1.16.0 rel_1_16_0
Mike Bayer [Wed, 21 May 2025 19:15:12 +0000 (15:15 -0400)] 
- 1.16.0

10 months agomy typo fix broke the build!
Mike Bayer [Wed, 21 May 2025 19:12:48 +0000 (15:12 -0400)] 
my typo fix broke the build!

Change-Id: I58ee64ce8eb9a0437d8e7a05fae481e40914f00e

10 months agodocument operations in terms of Operations
Mike Bayer [Wed, 21 May 2025 19:09:18 +0000 (15:09 -0400)] 
document operations in terms of Operations

Change-Id: I6d0da502bd39252c74a4c240b08530b9b2ebdc37

10 months agoensure conv is applied to all reflected index and constraint names
Mike Bayer [Wed, 21 May 2025 14:09:46 +0000 (10:09 -0400)] 
ensure conv is applied to all reflected index and constraint names

The autogenerate process will now apply the :meth:`.Operations.f` modifier
to the names of all constraints and indexes that are reflected from the
target database when generating migrations, which has the effect that these
names will not have any subsequent naming conventions applied to them when
the migration operations proceed.  As reflected objects already include the
exact name that's present in the database, these names should not be
modified.   The fix repairs the issue when using custom naming conventions
which feature the ``%(constraint_name)s`` token would cause names to be
double-processed, leading to errors in migration runs.

Fixes: #264
Change-Id: Ie48f65c41e66f3698cafe558cafa189f524c8cdf

10 months agostill more path reprs
Mike Bayer [Wed, 21 May 2025 13:47:01 +0000 (09:47 -0400)] 
still more path reprs

Change-Id: Ic4d0a3a62586be58461f1c688c7247d4b570aaf6

10 months agomore tweaks
Mike Bayer [Wed, 21 May 2025 03:40:33 +0000 (23:40 -0400)] 
more tweaks

this is primarily cleanup of the changelog section which is
extensive for this release.

Additionally, limited Config.config_file_name and Config.toml_file_name
to string only when accessed, making use of _preserving_path_as_str()
for these on the parameter side.

Change-Id: I9bec7bdc7fcaa79efeccb5e6f584be3f328499f2

10 months agouse plain string to stringify Path
Mike Bayer [Wed, 21 May 2025 01:10:52 +0000 (21:10 -0400)] 
use plain string to stringify Path

Change-Id: I5bed8767ccee317aa5bdb8ec06725939a22a8446

10 months agoMerge "Replace use of utcnow() with now() for Python 3.13 compatibility, Fixes #1643...
Michael Bayer [Wed, 21 May 2025 00:17:41 +0000 (00:17 +0000)] 
Merge "Replace use of utcnow() with now() for Python 3.13 compatibility, Fixes #1643" into main

10 months agoReplace use of utcnow() with now() for Python 3.13 compatibility, Fixes #1643
Jens Troeger [Tue, 20 May 2025 21:01:45 +0000 (17:01 -0400)] 
Replace use of utcnow() with now() for Python 3.13 compatibility, Fixes #1643

Fixed issue where use of deprecated ``utcnow()`` function would generate
warnings.  Has been replaced with ``now(UTC)``.  Pull request courtesy
Jens Tröger.

Fixes: #1643
Closes: #1644
Pull-request: https://github.com/sqlalchemy/alembic/pull/1644
Pull-request-sha: 1ddb3caa4a8bc7487d070d39c24d5e5e609e0688

Change-Id: Ide0f830d33529c5d4d9540b5e043954f440f9016

10 months agonow get %(here)s to work for all special pyproject config values
Mike Bayer [Tue, 20 May 2025 20:32:31 +0000 (16:32 -0400)] 
now get %(here)s to work for all special pyproject config values

batting 1000 here, the %(here)s token was totally not handled
in any of version_locations, prepend_sys_path_paths, post_write_hooks.
All params that definitely need this token.

Change-Id: Ib829bb22f0d86dd27baef83eb0b31c236a12d65c

10 months agofix list_templates command
Mike Bayer [Tue, 20 May 2025 19:56:12 +0000 (15:56 -0400)] 
fix list_templates command

in switching this to use pathlib, the template names were coming out
as long absolute paths

Change-Id: I3ba7de601a11fbd28e96c63e7bdcfd4accdfd858

10 months agomake sure no-ini-file actually works
Mike Bayer [Tue, 20 May 2025 19:17:54 +0000 (15:17 -0400)] 
make sure no-ini-file actually works

because Config has an alembic.ini path in it by default, if the file
doesnt exist it will raise when you call get_main_option().  make sure
no alembic function calls upon get_main_option() directly at all so that
configparser is entirely not required

Change-Id: Idae5979778e67075b3b233c902bfa4c70a2e614e

10 months agodoc edits.
Mike Bayer [Tue, 20 May 2025 18:35:53 +0000 (14:35 -0400)] 
doc edits.

Also more changes are needed as we observe alembic does not run
without alembic.ini present, which it should.

Change-Id: Iff2393c79d3cb8b7ed8e653a08cc5f579fa31717

10 months agouse Path.name for split target
Mike Bayer [Tue, 20 May 2025 14:12:30 +0000 (10:12 -0400)] 
use Path.name for split target

some code dealing with .pyc names that needs the first token of the
dot-separated filename is clearer based on path.name, full filename,
rather than .stem

Change-Id: I2b289f279903027d32e071c79d60eac293f2bdb5

10 months agoMerge "use pathlib for file operations across the board" into main
Michael Bayer [Tue, 20 May 2025 14:10:52 +0000 (14:10 +0000)] 
Merge "use pathlib for file operations across the board" into main

10 months agouse pathlib for file operations across the board
Mike Bayer [Mon, 19 May 2025 17:06:56 +0000 (13:06 -0400)] 
use pathlib for file operations across the board

The command, config and script modules now rely on ``pathlib.Path`` for
internal path manipulations, instead of ``os.path()`` operations.   Public
API functions that accept string directories and filenames continue to do
so but also accept ``os.PathLike`` objects.  Public API functions and
accessors that return paths as strings continue to do so.   Private API
functions and accessors, i.e. all those that are prefixed with an
underscore, may now return a Path object rather than a string to indicate
file paths.

Change-Id: I7c79cdecd7e866c7086422079aa92077816acec3

10 months agoMerge "add autogen render for drop_constraint.if_exists" into main
Michael Bayer [Mon, 19 May 2025 22:24:40 +0000 (22:24 +0000)] 
Merge "add autogen render for drop_constraint.if_exists" into main

10 months agoremove py 3.10 from github pep 484 action
Mike Bayer [Mon, 19 May 2025 16:30:37 +0000 (12:30 -0400)] 
remove py 3.10 from github pep 484 action

tomllib isn't present

Change-Id: I942b6b4fbbb85663a35e9373bb33ca92651070fb

10 months agoadd autogen render for drop_constraint.if_exists
Mike Bayer [Mon, 19 May 2025 16:24:44 +0000 (12:24 -0400)] 
add autogen render for drop_constraint.if_exists

I've maintained all along that #1650 and #1626 are the same thing
and should have been one big PR.   Here we complete the autogen
portion of the #1650 PR that was omitted.

Fixes: #1650
Change-Id: I0e98feca6ce9aa908f27c8bf7af036d116f93404

10 months agoMerge "allow pep 621 configuration" into main
Michael Bayer [Mon, 19 May 2025 16:16:01 +0000 (16:16 +0000)] 
Merge "allow pep 621 configuration" into main

10 months agoMerge "Add file_path_separator to apply to all path splitting" into main
Michael Bayer [Mon, 19 May 2025 16:15:52 +0000 (16:15 +0000)] 
Merge "Add file_path_separator to apply to all path splitting" into main

10 months agoAdd support of IF [NOT] EXISTS for ADD/DROP COLUMN in Postgresql
Louis-Amaury Chaib [Mon, 19 May 2025 13:11:00 +0000 (09:11 -0400)] 
Add support of IF [NOT] EXISTS for ADD/DROP COLUMN in Postgresql

Added :paramref:`.Operations.add_column.if_not_exists` and
:paramref:`.Operations.drop_column.if_exists` to render ``IF [NOT] EXISTS``
for ``ADD COLUMN`` and ``DROP COLUMN`` operations, a feature available on
some database backends such as PostgreSQL, MariaDB, as well as third party
backends.  The parameters also support autogenerate rendering allowing them
to be turned on via a custom :class:`.Rewriter`. Pull request courtesy of
Louis-Amaury Chaib (@lachaib).

Fixes: #1626
Closes: #1627
Pull-request: https://github.com/sqlalchemy/alembic/pull/1627
Pull-request-sha: c503b049f453a12e7fdb87464606cddd58ad306c

Change-Id: I4d55f65f072b9f03698b2f45f066872b5c3e8c58

10 months agoallow pep 621 configuration
Mike Bayer [Tue, 13 May 2025 14:14:10 +0000 (10:14 -0400)] 
allow pep 621 configuration

Added optional :pep:`621` support to Alembic, where a subset of the
project-centric configuration normally found in the ``alembic.ini`` file
can now be retrieved from the project-wide ``pyproject.toml`` file.   A new
init template ``pyproject`` is added which illustrates a basic :pep:`621`
setup.  The :pep:`621` feature supports configuration values that are
relevant to code locations and code production only; it does not
accommodate database connectivity, configuration, or logging configuration.
These latter configurational elements remain as elements that can be
present either in the ``alembic.ini`` file, or retrieved elsewhere within
the ``env.py`` file.   The change also allows the ``alembic.ini`` file to
be completely optional if the ``pyproject.toml`` file contains a base
alembic configuration section.

Fixes: #1082
Change-Id: I7c6d1e68eb570bc5273e3500a17b342dfbd69d1b

10 months agoExecuteSQLOp rendering respects alembic_module_prefix
Avery Fischer [Tue, 13 May 2025 16:44:27 +0000 (12:44 -0400)] 
ExecuteSQLOp rendering respects alembic_module_prefix

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description

Rendering ExecuteSQLOp did not respect the `alembic_module_prefix` setting due
to having `op.` hard-coded in its template.

This change updates the render logic to use the same
`_alembic_autogenerate_prefix()` as it seems the rest of the ops use.

### Checklist

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

Fixes #1656

Closes: #1657
Pull-request: https://github.com/sqlalchemy/alembic/pull/1657
Pull-request-sha: c67f4b7ce25c363d525cd2483370b0be024160d9

Change-Id: I6ca36642ed3755a2d96824498502ada6ae16f714

10 months agoAdd file_path_separator to apply to all path splitting
Mike Werezak [Sat, 26 Apr 2025 18:57:24 +0000 (14:57 -0400)] 
Add file_path_separator to apply to all path splitting

Added new option to the ConfigParser config (typically via ``alembic.ini``)
``path_separator``. This new option supersedes the previous similar
option ``version_path_separator``.   The new ``path_separator`` option
applies to the path splitting mechanism of both the ``version_locations``
option as well as the ``prepend_sys_path`` option, and in newly
rendered ``alembic.ini`` files will use the value ``os``, which means to
use the operating system path separator when splitting these string values
into a list of paths.

The new attribute applies necessary os-dependent path splitting to the
``prepend_sys_path`` option so that windows paths which contain drive
letters with colons are not inadvertently split, whereas previously
os-dependent path splitting were only available for the
``version_locations`` option.

Existing installations that do not have ``path_separator`` present
will continue to make use of ``version_path_separator`` when parsing the
``version_locations`` option, or splitting on spaces / commas if
``version_path_separator`` is also not present.  ``prepend_sys_path`` will
continue to be split on spaces/commas/colons if ``path_separator`` is
not present.   Under all of these fallback conditions, a deprecation
warning is now emitted encouraging to set ``path_separator``.

Pull request courtesy Mike Werezak.

This change also begins to move some of the role of interpreting
of specific config options into the Config object.  This process will
continue as we look to add toml support to config.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #1330
Closes: #1331
Pull-request: https://github.com/sqlalchemy/alembic/pull/1331
Pull-request-sha: f16b35d69acddd046cbba8f28e46219c872c151d

Change-Id: Idef47e8a6947210f1eb63c3d16c4be553effa3a2

10 months agoadd SECURITY.md
Mike Bayer [Tue, 13 May 2025 13:44:25 +0000 (09:44 -0400)] 
add SECURITY.md

Change-Id: I7cecd7d6038b0aae4ef815ba024f1d0f105fcb8e

11 months agoMerge "use pep639" into main
Michael Bayer [Thu, 8 May 2025 13:01:07 +0000 (13:01 +0000)] 
Merge "use pep639" into main

11 months agouse pep639
Mike Bayer [Wed, 7 May 2025 15:34:49 +0000 (11:34 -0400)] 
use pep639

The pyproject.toml configuration has been amended to use the updated
:pep:`639` configuration for license, which eliminates loud deprecation
warnings when building the package.   Note this necessarily bumps
setuptools build requirement to 77.0.3.

Also bump black, flake8, see what's coming.

this change is modeled after the same change made in dogpile.cache
which has since been released.

Fixes: #1637
Change-Id: I9a9e22ebaebe0d257f003f5ff5b81088df3c8901

11 months agoMerge "Refactor `CommandLine` command registration" into main
Michael Bayer [Wed, 7 May 2025 15:15:12 +0000 (15:15 +0000)] 
Merge "Refactor `CommandLine` command registration" into main

11 months agoRefactor `CommandLine` command registration
Mikhail Bulash [Tue, 29 Apr 2025 19:49:35 +0000 (15:49 -0400)] 
Refactor `CommandLine` command registration

Added new :meth:`.CommandLine.register_command` method to
:class:`.CommandLine`, intended to facilitate adding custom commands to
Alembic's command line tool with minimal code required; previously this
logic was embedded internally and was not publicly accessible.  A new
recipe demonstrating this use is added.   Pull request courtesy Mikhail
Bulash.

Fixes: #1610
Closes: #1611
Pull-request: https://github.com/sqlalchemy/alembic/pull/1611
Pull-request-sha: d2ffce008317508449de9bd0bce3ff9076c5d90f

Change-Id: Icab9978357915e81bb52a9f0717f21d5ee7f8341

11 months agoSupport DROP CONSTRAINT IF EXISTS
Aaron Griffin [Wed, 30 Apr 2025 12:42:49 +0000 (08:42 -0400)] 
Support DROP CONSTRAINT IF EXISTS

Added :paramref:`.op.drop_constraint.if_exists` parameter to
:func:`.op.drop_constraint` which will render "DROP CONSTRAINT IF EXISTS".
Pull request courtesy Aaron Griffin.

Also attempting to fix unrelated issue w/ test_stubs and python
versions which may be in a separate patch if it can't work here

Fixes: #1650
Closes: #1651
Pull-request: https://github.com/sqlalchemy/alembic/pull/1651
Pull-request-sha: 1c3c0d388d36fa60b9aaa013873a415488ed7796

Change-Id: I96378d45dd00898975f450299e6f1344bb65ccff

12 months agoFix more type hint of server_default
Denis Laxalde [Wed, 2 Apr 2025 21:47:44 +0000 (17:47 -0400)] 
Fix more type hint of server_default

Follow-up commit db12e1918556dd463847db9ffb3e761231df9b1d (which is probably sufficient for type checking) by making all annotations of server_default consistent.

Closes: #1642
Pull-request: https://github.com/sqlalchemy/alembic/pull/1642
Pull-request-sha: f47c77942042a0cb3432e916f5b307aed5225533

Change-Id: Ida7ada422339caeeb368fa51463a173642dd67a7

12 months agofix `server_default` type hint
Charly Laurent [Tue, 1 Apr 2025 18:21:00 +0000 (14:21 -0400)] 
fix `server_default` type hint

### Description

The docstring of `alter_column` states: "Set to `None` to have the default removed". The type hint should accept None.

### Checklist

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

Fixes: #1639
Closes: #1641
Pull-request: https://github.com/sqlalchemy/alembic/pull/1641
Pull-request-sha: 6642187d254681712443039a95cc1f3110549654

Change-Id: Icb7246b47805d9b2c1ab70d4e26f3e09354fe190

12 months agoVersion 1.15.3 placeholder
Mike Bayer [Fri, 28 Mar 2025 13:52:16 +0000 (09:52 -0400)] 
Version 1.15.3 placeholder

12 months ago- 1.15.2 rel_1_15_2
Mike Bayer [Fri, 28 Mar 2025 13:50:14 +0000 (09:50 -0400)] 
- 1.15.2

12 months agofix AlterColumnOp modify_name ignorance
el [Fri, 28 Mar 2025 13:22:29 +0000 (09:22 -0400)] 
fix AlterColumnOp modify_name ignorance

Fixed issue where the "modified_name" of :class:`.AlterColumnOp` would not
be considered when rendering op directives for autogenerate. While
autogenerate cannot detect changes in column name, this would nonetheless
impact approaches that made use of this attribute in rewriter recipes. Pull
request courtesy lenvk.

Fixes: #1635
Closes: #1636
Pull-request: https://github.com/sqlalchemy/alembic/pull/1636
Pull-request-sha: dd103354dcf9cd8db30c66a9a4d3879e4f1c5499

Change-Id: I3e4976a3e703ecd8d69ec208b2d225a8bf6a8251

12 months agopep484 updates, again
Mike Bayer [Fri, 28 Mar 2025 13:21:49 +0000 (09:21 -0400)] 
pep484 updates, again

I merged the diff for the other PR as well, had to revert,
trying again

Change-Id: Icc28241d68626496e7c7857edb97eda0a9cf2219

12 months agoRevert "pep484 updates"
Mike Bayer [Fri, 28 Mar 2025 13:20:42 +0000 (09:20 -0400)] 
Revert "pep484 updates"

This reverts commit 03aeeb0c3701d67134885c85b187e9e6966d7d55.

12 months agopep484 updates
Mike Bayer [Fri, 28 Mar 2025 12:38:57 +0000 (08:38 -0400)] 
pep484 updates

Change-Id: I7e7d254dcff3e26f92b413596246409b1dfaab16

13 months agoMerge "Add TextClause to alter_column's server_default fields." into main
Federico Caselli [Wed, 5 Mar 2025 19:49:26 +0000 (19:49 +0000)] 
Merge "Add TextClause to alter_column's server_default fields." into main

13 months agoAdd TextClause to alter_column's server_default fields.
DanCardin [Tue, 4 Mar 2025 21:07:59 +0000 (16:07 -0500)] 
Add TextClause to alter_column's server_default fields.

Given sqlalchemy models with server_defaults, alembic may autogenerate
`existing_server_default=sa.text("...")`, which fails typechecking on
the resultant migration because `TextClause` is not currently a valid
annotated type.

Closes: #1577
Pull-request: https://github.com/sqlalchemy/alembic/pull/1577
Pull-request-sha: e21d07e55847f1e78e53f4f04bc2e458945f83fe

Change-Id: I583748e16f3fccb4d58d8c4aa0e33c00b029523c

13 months agoVersion 1.15.2 placeholder
Mike Bayer [Tue, 4 Mar 2025 22:02:54 +0000 (17:02 -0500)] 
Version 1.15.2 placeholder

13 months ago- 1.15.1 rel_1_15_1
Mike Bayer [Tue, 4 Mar 2025 21:59:14 +0000 (16:59 -0500)] 
- 1.15.1

13 months agoMerge "fix template files include" into main
Michael Bayer [Tue, 4 Mar 2025 21:58:46 +0000 (21:58 +0000)] 
Merge "fix template files include" into main

13 months agoFix linting with ruff provided in alembic.ini by scratch
Rishat Fayzullin [Tue, 4 Mar 2025 20:32:44 +0000 (15:32 -0500)] 
Fix linting with ruff provided in alembic.ini by scratch

Fixes: #1614
Closes: #1615
Pull-request: https://github.com/sqlalchemy/alembic/pull/1615
Pull-request-sha: 92342fac19adf62a148ab937d1dc82417adb6e17

Change-Id: I02f801007a877e8498fab6dd3159b65bb2412c01

13 months agofix template files include
Mike Bayer [Tue, 4 Mar 2025 19:33:59 +0000 (14:33 -0500)] 
fix template files include

Fixed an issue in the new :pep:`621` ``pyproject.toml`` layout that
prevented Alembic's template files from being included in the ``.whl`` file
in the distribution.

Fixes: #1616
Change-Id: I059e69841f918985d999aafad1319a0c7fd9d2d5

13 months agoVersion 1.15.1 placeholder
Mike Bayer [Tue, 4 Mar 2025 17:57:49 +0000 (12:57 -0500)] 
Version 1.15.1 placeholder

13 months ago- 1.15.0 rel_1_15_0
Mike Bayer [Tue, 4 Mar 2025 17:56:19 +0000 (12:56 -0500)] 
- 1.15.0

13 months agoremove some additional legacy setuptools elements
Mike Bayer [Tue, 4 Mar 2025 17:52:26 +0000 (12:52 -0500)] 
remove some additional legacy setuptools elements

copying dogpile.cache here, most importantly remove the
tag-build=dev thing since release scripts don't make edits
to pyproject.toml on this front.

Change-Id: I1fdead960c859a491376a059760938975fd17746

13 months agodont stringify uq deferrable
Mike Bayer [Wed, 26 Feb 2025 14:09:51 +0000 (09:09 -0500)] 
dont stringify uq deferrable

Fixed autogenerate rendering bug where the ``deferrable`` element of
``UniqueConstraint``, a bool, were being stringified rather than repr'ed
when generating Python code.

Fixes: #1613
Change-Id: I24bf7f3542566994559144c08cde2766d9ff4fe1

13 months agouse pep 621
Mike Bayer [Thu, 13 Feb 2025 16:53:25 +0000 (11:53 -0500)] 
use pep 621

Installation has been converted to use :pep:`621`, e.g. ``pyproject.toml``.

note that the introduction of pyproject with min python version of 3.9
is also consumed by Black which now wants to format a few test files
differently, so that is included as well.

Change-Id: I7f61abded37fd3f1d7bf32e3228fe97902029d19

13 months agochangelog edits
Mike Bayer [Thu, 13 Feb 2025 16:47:39 +0000 (11:47 -0500)] 
changelog edits

Change-Id: I8acc5d84ca10f839727fb159d5283fe74763e7a6

13 months agoMerge "Render labels in autogenerate index" into main
Michael Bayer [Wed, 12 Feb 2025 19:47:13 +0000 (19:47 +0000)] 
Merge "Render labels in autogenerate index" into main

13 months agomore 3.8 cleanups
Federico Caselli [Mon, 10 Feb 2025 20:46:34 +0000 (21:46 +0100)] 
more 3.8 cleanups

Change-Id: I7382b37781c43701020442d29f45a4bef274fffc

13 months agoremove python 3.8 from github files
Mike Bayer [Mon, 10 Feb 2025 18:47:53 +0000 (13:47 -0500)] 
remove python 3.8 from github files

they dont have 3.8 anymore

Change-Id: I3ccf04e83649f1b1112bb402b54345b7e9bf7180

13 months agoremove sqla13 tags from github files
Mike Bayer [Mon, 10 Feb 2025 18:40:59 +0000 (13:40 -0500)] 
remove sqla13 tags from github files

in ab446ab302ffb2884d0d95e2c766 we forgot to remove
the sqla 3.13 tags from the github actions

Change-Id: I1c32ab16adb1c62e061e0bd4458f07ef71a96bc0

13 months agodrop SQLAlchemy 1.3, Python 3.8
Mike Bayer [Sat, 8 Feb 2025 17:04:53 +0000 (12:04 -0500)] 
drop SQLAlchemy 1.3, Python 3.8

Jenkins issues reveal that SQLAlchemy 1.3's testing provision has
unidentified deficiencies that are causing instability with the
mssql engine.   As provisioning was highly refactored in 1.4, just drop
1.3 support rather than trying to figure out the exact thing that
changed.

Support for SQLAlchemy 1.3, which was EOL as of 2021, is now dropped from
Alembic as of version 1.15.0.

Support for Python 3.8 is dropped as of Alembic 1.15.0.  Python 3.8 is EOL.

Try pytest 8.3 as this seems to be running fine for SQLAlchemy

Change-Id: I06614a6f73d5b1a1ac5b9b04225ecb305f5b35ee

13 months agoRender labels in autogenerate index
Federico Caselli [Sat, 8 Feb 2025 11:57:31 +0000 (12:57 +0100)] 
Render labels in autogenerate index

Index autogenerate will now render labels for expressions
that use them. This is useful when applying operator classes
in PostgreSQL that can be keyed on the label name.

Fixes: #1603
Change-Id: I187a944a5021e643e264ee1ec97807f6573e5f2f

14 months agoAvoid D103 linter warnings via script.py.mako
Peter Cock [Wed, 6 Nov 2024 17:07:02 +0000 (12:07 -0500)] 
Avoid D103 linter warnings via script.py.mako

Added a basic docstring to the migration template files so that the
upgrade/downgrade methods pass the D103 linter check which requires a
docstring for public functions.  Pull request courtesy Peter Cock.

Fixes: #1567
Closes: #1568
Pull-request: https://github.com/sqlalchemy/alembic/pull/1568
Pull-request-sha: fa3bcd5926cc2523ac6f05c3c1e8c4eeafc55dda

Change-Id: I14b7863dfef01edca9c94d8dff4109efd274df3c

14 months agorefactor: add revision context to AutogenerateDiffsDetected so that wrappers may...
Louis-Amaury Chaib [Sat, 1 Feb 2025 09:02:34 +0000 (04:02 -0500)] 
refactor: add revision context to AutogenerateDiffsDetected so that wrappers may make other formatting of the diff

### Description
As discussed in #1597, AutogenerateDiffsDetected should hold contextual information so that command can be wrapped for another format (CI, pre-commit hook...)

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #1598
Pull-request: https://github.com/sqlalchemy/alembic/pull/1598
Pull-request-sha: 7799320ad3c1a1bd769254d610288c97f85cb345

Change-Id: Id08bc52a0586063f177736a36a61f96232459f1c

14 months agofix tox error on python 3.8
Federico Caselli [Thu, 23 Jan 2025 20:50:14 +0000 (21:50 +0100)] 
fix tox error on python 3.8

Change-Id: I1f2f7789c803024f8feec4d8626564bbec04b386

14 months agoimprove test compat on windows and update gh workflows
Federico Caselli [Mon, 20 Jan 2025 19:36:17 +0000 (20:36 +0100)] 
improve test compat on windows and update gh workflows

Change-Id: Ia58a2db5310626ac77d7bae73fbb978f01194384

14 months agoVersion 1.14.2 placeholder
Mike Bayer [Sun, 19 Jan 2025 23:15:46 +0000 (18:15 -0500)] 
Version 1.14.2 placeholder

14 months ago- 1.14.1 rel_1_14_1
Mike Bayer [Sun, 19 Jan 2025 23:14:41 +0000 (18:14 -0500)] 
- 1.14.1

15 months agoDocs: fix layout issue in autogenerate (#1589)
Michiel W. Beijen [Wed, 8 Jan 2025 19:02:11 +0000 (20:02 +0100)] 
Docs: fix layout issue in autogenerate (#1589)

During building of the docs, I got this warning:

> alembic/docs/build/autogenerate.rst:733: WARNING: Bullet list ends without a blank line; unexpected unindent. [docutils]

This PR fixes the problem

15 months agoupdate test to support sqlalchemy inherit schema change
Federico Caselli [Sat, 4 Jan 2025 15:33:19 +0000 (16:33 +0100)] 
update test to support sqlalchemy inherit schema change

Change-Id: Ie48d45c63442001aeaa6a81dc909af32af303aa2

15 months ago2025
Mike Bayer [Thu, 2 Jan 2025 21:43:17 +0000 (16:43 -0500)] 
2025

Change-Id: Ifb33b8df2f838851f329415fa70f494acb4ccde5

15 months agocheck for variants (recursion branch) first in all cases
Mike Bayer [Tue, 24 Dec 2024 15:30:10 +0000 (10:30 -0500)] 
check for variants (recursion branch) first in all cases

Fixed bug where autogen render of a "variant" type would fail to catch the
variants if the leading type were a dialect-specific type, rather than a
generic type.

Fixes: #1585
Change-Id: I189e9ab3674b09700f2c774b600f6ff3abb52cd0

16 months agofixed typo on "Auto generating migrations" page, Fixes: #1574 (#1575)
John Higgins [Tue, 3 Dec 2024 20:52:00 +0000 (12:52 -0800)] 
fixed typo on "Auto generating migrations" page, Fixes: #1574 (#1575)

16 months agoblock write_pyi tests for py313
Mike Bayer [Tue, 3 Dec 2024 20:13:42 +0000 (15:13 -0500)] 
block write_pyi tests for py313

write_pyi.py seems to produce entirely broken results
on python 3.13

Change-Id: I037b917d9ca346e455848b0cd6d41e6ce152ddd2

16 months agoMerge "ensure rename_column works on SQLite" into main
Michael Bayer [Fri, 29 Nov 2024 17:19:37 +0000 (17:19 +0000)] 
Merge "ensure rename_column works on SQLite" into main

16 months agoensure rename_column works on SQLite
Mike Bayer [Fri, 29 Nov 2024 16:58:53 +0000 (11:58 -0500)] 
ensure rename_column works on SQLite

Modified SQLite's dialect to render "ALTER TABLE <t> RENAME COLUMN" when
:meth:`.Operations.alter_column` is used with a straight rename, supporting
SQLite's recently added column rename feature.

References: #1576
Change-Id: Ia84c4fda144c2767393e4748ced60479016f2c91

16 months agosupport separation of Numeric/Float
Mike Bayer [Mon, 25 Nov 2024 18:57:58 +0000 (13:57 -0500)] 
support separation of Numeric/Float

in [1] we are considering separating Numeric and Float.
For Alembic PostgreSQL backend we need this isinstance therefore
to check for both Numeric and Float.
By keeping it to these two types, rather than targeting the
NumericCommon type being added in [1], the patch can work with
SQLAlchemy without the separation change as well.

[1] https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3587

Change-Id: I0c956ba8797e38a62ea630ab65cd53779bbf1972