]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/log
thirdparty/sqlalchemy/alembic.git
2 years ago- 1.11.2 rel_1_11_2
Mike Bayer [Fri, 4 Aug 2023 13:54:59 +0000 (09:54 -0400)] 
- 1.11.2

2 years agoAdded parameters if_exists and if_not_exists for index operations.
Адриан Максим Александрович [Tue, 11 Jul 2023 19:31:29 +0000 (15:31 -0400)] 
Added parameters if_exists and if_not_exists for index operations.

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

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

As mentioned in #151, IF EXISTS/IF NOT EXISTS syntax was implemented in SQLAlchemy 2.0. This request adds an ability to use them for index operations.

If the issue implies to implement all the possible cases with these directives, I could continue working on it 🙂

### 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
- [ ] 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.
- [x] 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: #1260
Pull-request: https://github.com/sqlalchemy/alembic/pull/1260
Pull-request-sha: 5ed62d17c349dc175521993c5a62b842f6ac624d

Change-Id: Ic0fec21e20d4a868e9e29275e540f3e09918d1ff

2 years agoMerge "Nulls not distinct support in postgresql" into main
mike bayer [Mon, 26 Jun 2023 19:01:48 +0000 (19:01 +0000)] 
Merge "Nulls not distinct support in postgresql" into main

2 years agoNulls not distinct support in postgresql
Federico Caselli [Thu, 8 Jun 2023 19:32:11 +0000 (15:32 -0400)] 
Nulls not distinct support in postgresql

Added support in autogenerate for NULLS NOT DISTINCT in
the PostgreSQL dialect.

Closes: #1249
Pull-request: https://github.com/sqlalchemy/alembic/pull/1249
Pull-request-sha: e4a7ffed54677d5aba9ab0251026a8a2a0e71278

Change-Id: I299a24fa7af4ae9387d6b48ce49fb516dfb84518

2 years agoFixed CLI output when running post_write hooks
Mathieu Défosse [Sat, 17 Jun 2023 17:46:08 +0000 (13:46 -0400)] 
Fixed CLI output when running post_write hooks

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

### Description
Just fixed badly written Python string interpolation. Used the `%` operator just like the lines above.

### 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: #1262
Pull-request: https://github.com/sqlalchemy/alembic/pull/1262
Pull-request-sha: 19d17f5d061319bbf142b45a593081da5fc1dda8

Change-Id: I89ef873935d7206a61f78a09139cd5ab192a2275

2 years agoUpdate black
Federico Caselli [Thu, 8 Jun 2023 19:42:44 +0000 (21:42 +0200)] 
Update black

Change-Id: I836b9a322819c07ec202fdcca4fd52818b994bff

2 years agoAdded typing to the default script mako templates.
Federico Caselli [Fri, 26 May 2023 20:01:48 +0000 (22:01 +0200)] 
Added typing to the default script mako templates.

Fixes: #1253
Change-Id: I00cae5daa8ebe9ba36bfac3af485a0e45a39f923

2 years agoVersion 1.11.2 placeholder
Mike Bayer [Wed, 17 May 2023 22:09:45 +0000 (18:09 -0400)] 
Version 1.11.2 placeholder

2 years ago- 1.11.1 rel_1_11_1
Mike Bayer [Wed, 17 May 2023 22:06:56 +0000 (18:06 -0400)] 
- 1.11.1

2 years agotypos
Mike Bayer [Wed, 17 May 2023 22:06:27 +0000 (18:06 -0400)] 
typos

Change-Id: I3946d5afc0fb876424659356a6b0e49f3ee5a8bc

2 years agoMerge "Define type for generic classes" into main
mike bayer [Wed, 17 May 2023 15:15:05 +0000 (15:15 +0000)] 
Merge "Define type for generic classes" into main

2 years agoMerge "restore drop_index.table_name, drop_constraint.type_ as positional" into main
mike bayer [Wed, 17 May 2023 13:12:43 +0000 (13:12 +0000)] 
Merge "restore drop_index.table_name, drop_constraint.type_ as positional" into main

2 years agoDefine type for generic classes
Federico Caselli [Tue, 16 May 2023 19:52:02 +0000 (21:52 +0200)] 
Define type for generic classes

Fixed typing use of :class:`~sqlalchemy.schema.Column` and other
generic SQLAlchemy classes.

Fixes: #1246
Change-Id: I5ee80395d626894a52e3395c9986213289576355

2 years agorestore drop_index.table_name, drop_constraint.type_ as positional
Mike Bayer [Tue, 16 May 2023 12:55:51 +0000 (08:55 -0400)] 
restore drop_index.table_name, drop_constraint.type_ as positional

These two API changes were identified as having legacy
use patterns and should be revisited using a deprecation warning
for removal in either 1.12 or 1.13.

Add documentation re: Alembic not using semver, fix
incorrect calling signature example in batch documentation.

Change-Id: I33dc5a8d058bcce77591bb037ae964e626a3387f
Fixes: #1243
Fixes: #1245
2 years agorestore Dict[str, str] as potential get_section() type
Mike Bayer [Tue, 16 May 2023 14:39:31 +0000 (10:39 -0400)] 
restore Dict[str, str] as potential get_section() type

Restored the output type of :meth:`.Config.get_section` to include
``Dict[str, str]`` as a potential return type, which had been changed to
immutable ``Mapping[str, str]``. When a section is returned and the default
is not used, a mutable dictionary is returned.

Change-Id: I6e2c67f00222d7a2b388f9294c5336fd8e2dec94
Fixes: #1244
2 years agoVersion 1.11.1 placeholder
Mike Bayer [Mon, 15 May 2023 19:46:46 +0000 (15:46 -0400)] 
Version 1.11.1 placeholder

2 years ago- 1.11.0 rel_1_11_0
Mike Bayer [Mon, 15 May 2023 19:44:58 +0000 (15:44 -0400)] 
- 1.11.0

2 years ago1.11.0 in changelog file; doc updates
Mike Bayer [Mon, 15 May 2023 19:19:11 +0000 (15:19 -0400)] 
1.11.0 in changelog file; doc updates

Change-Id: I5098f9fe2bf57ad93f400e34d914ae0e3b45c747

2 years agoMerge "dont compare unique constraint and index sigs to each other" into main
mike bayer [Fri, 12 May 2023 21:15:55 +0000 (21:15 +0000)] 
Merge "dont compare unique constraint and index sigs to each other" into main

2 years agoImprove commit 497c6c86b9547eed2ac297b1618300430578b86f
Federico Caselli [Fri, 12 May 2023 19:59:15 +0000 (21:59 +0200)] 
Improve commit 497c6c86b9547eed2ac297b1618300430578b86f

Follow up of I91b453c8848dc5d24d63840bfd7ce4d22dd0e693 to improve some
leftover changes.

Change-Id: I368b93df4d8bd6782b04042ab7872276ff00e56b

2 years agodont compare unique constraint and index sigs to each other
Mike Bayer [Fri, 12 May 2023 16:40:01 +0000 (12:40 -0400)] 
dont compare unique constraint and index sigs to each other

Fixed regression caused by :ticket:`1166` released in version 1.10.0 which
caused MySQL unique constraints with multiple columns to not compare
correctly within autogenerate, due to different sorting rules on unique
constraints vs. indexes, which in MySQL are shared constructs.

Change-Id: I5687dde95281f237fd73367d145b9c62e2576a3a
Fixes: #1240
2 years agoMerge "add user_module_prefix param for render_python_code" into main
mike bayer [Fri, 12 May 2023 16:59:33 +0000 (16:59 +0000)] 
Merge "add user_module_prefix param for render_python_code" into main

2 years agoMerge "Added ``op.run_async``." into main
mike bayer [Fri, 12 May 2023 16:59:04 +0000 (16:59 +0000)] 
Merge "Added ``op.run_async``." into main

2 years agoadd user_module_prefix param for render_python_code
tangkikodo [Thu, 11 May 2023 20:43:05 +0000 (16:43 -0400)] 
add user_module_prefix param for render_python_code

Fixed issue where :func:`.autogenerate.render_python_code` function did not
provide a default value for the ``user_module_prefix`` variable, leading to
``NoneType`` errors when autogenerate structures included user-defined
types. Added new parameter
:paramref:`.autogenerate.render_python_code.user_module_prefix` to allow
this to be set as well as to default to ``None``. Pull request courtesy
tangkikodo.

Fixes #1235
Closes: #1233
Pull-request: https://github.com/sqlalchemy/alembic/pull/1233
Pull-request-sha: 6fa3bc1ce4f2130bf7a28282a84e3bb9a3223304

Change-Id: Ic21eec87f373a9518513a6a308f16e5d2b5ebf81

2 years agoAdded ``op.run_async``.
Federico Caselli [Sat, 29 Apr 2023 21:25:21 +0000 (23:25 +0200)] 
Added ``op.run_async``.

Added :meth:`.Operations.run_async` to the operation module to allow
running async functions in the ``upgrade`` or ``downgrade`` migration
function when running alembic using an async dialect.
This function will receive as first argument an
class:`~sqlalchemy.ext.asyncio.AsyncConnection` sharing the transaction
used in the migration context.

also restore the .execute() method to BatchOperations

Fixes: #1231
Change-Id: I3c3237d570be3c9bd9834e4c61bb3231bfb82765

2 years agoMerge "keyword only arguments in ops" into main
mike bayer [Fri, 12 May 2023 16:00:07 +0000 (16:00 +0000)] 
Merge "keyword only arguments in ops" into main

2 years agoRemoved server default quoting from compare
Federico Caselli [Thu, 11 May 2023 19:49:14 +0000 (21:49 +0200)] 
Removed server default quoting from compare

Don't modify the metadata server default when comparing it in the
autogenerate process.
This impacts the value passes to user provided functions passed in
:paramref:`.EnvironmentContext.configure.compare_server_default`
and third party dialect that implement a custom ``compare_server_default``.

Fixes: #1178
Change-Id: Ib429efcf9077337f768ad5aad91659867e89391a

2 years agokeyword only arguments in ops
Mike Bayer [Fri, 25 Nov 2022 15:31:20 +0000 (10:31 -0500)] 
keyword only arguments in ops

Argument signatures of Alembic operations now enforce keyword-only
arguments as passed as keyword and not positionally, such as
:paramref:`.Operations.create_table.schema`,
:paramref:`.Operations.add_column.type_`, etc.

Change-Id: I91b453c8848dc5d24d63840bfd7ce4d22dd0e693
Fixes: #1130
2 years agoMerge "Fix compat issue with older SQLAlchemy versions." into main
mike bayer [Tue, 9 May 2023 23:36:42 +0000 (23:36 +0000)] 
Merge "Fix compat issue with older SQLAlchemy versions." into main

2 years agoFix compat issue with older SQLAlchemy versions.
Federico Caselli [Mon, 8 May 2023 21:05:40 +0000 (23:05 +0200)] 
Fix compat issue with older SQLAlchemy versions.

Added placeholder classes for ``Computed`` and ``Identity`` when older 1.x
SQLAlchemy versions are in use, namely prior to SQLAlchemy 1.3.11 when the
``Computed`` construct was introduced. Previously these were set to None,
however this could cause issues with certain codepaths that were using
``isinstance()`` such as one within "batch mode".

Fixes: #1237
Change-Id: I033712158baa68cca6a56bd41d0636109e156b86

2 years agoAdd Operations and BatchOperations stub methods
CaselIT [Thu, 16 Mar 2023 23:50:53 +0000 (00:50 +0100)] 
Add Operations and BatchOperations stub methods

Updated stub generator script to also add stubs method definitions
for the :class:`.Operations` class and the :class:`.BatchOperations`
class obtained from :meth:`.Operations.batch_alter_table`.

Repaired the return signatures for :class:`.Operations` that mostly
return ``None``, and were erroneously referring to ``Optional[Table]``
in many cases.

Fixes: #1093
Change-Id: I98d38dd5a1e719b4dbbc1003746ec28f26c27808

2 years agoMerge "Added quiet option to command line" into main
Federico Caselli [Thu, 4 May 2023 20:21:28 +0000 (20:21 +0000)] 
Merge "Added quiet option to command line" into main

2 years agoMerge "Fix ExcludeConstraint with func." into main
mike bayer [Wed, 3 May 2023 13:19:07 +0000 (13:19 +0000)] 
Merge "Fix ExcludeConstraint with func." into main

2 years agoMerge "Replace find with find_namespace in setuptools config." into main
mike bayer [Sun, 30 Apr 2023 14:44:01 +0000 (14:44 +0000)] 
Merge "Replace find with find_namespace in setuptools config." into main

2 years agodocument constraint behavior for add_column()
Mike Bayer [Sat, 29 Apr 2023 04:32:16 +0000 (00:32 -0400)] 
document constraint behavior for add_column()

note which constraints are generated from Column (nullable,
single column FOREIGN KEY) and which
are not (PRIMARY KEY, CHECK, UNIQUE, etc.).

Change-Id: I030f2b4e17b08a63e0543567cf01ba03e8752d79
Fixes: #1232
2 years agoAdded quiet option to command line
CaselIT [Sun, 2 Apr 2023 10:21:00 +0000 (12:21 +0200)] 
Added quiet option to command line

Added quiet option to the command line, using the ``-q/--quiet``
option. This flag will prevent alembic from logging anything
to stdout.

Fixes: #1109
Change-Id: I7d9fac05d93e07efaefd87a582a7e785891798ef

2 years agoFix ExcludeConstraint with func.
Federico Caselli [Fri, 28 Apr 2023 19:24:43 +0000 (21:24 +0200)] 
Fix ExcludeConstraint with func.

Fix autogenerate issue with PostgreSQL :class:`.ExcludeConstraint`
that included sqlalchemy functions. The function text was previously
rendered as a plain string without surrounding with ``text()``.

Fixes: #1230
Change-Id: I0d59e04d5a64132ed86f92a27e4247ac9703f3e0

2 years agoFollowup / fixup: apply 'black' code formatting to a couple of missed docstrings
James Addison [Wed, 26 Apr 2023 20:29:53 +0000 (16:29 -0400)] 
Followup / fixup: apply 'black' code formatting to a couple of missed docstrings

### Description
Follow-up / completion of #1220.  That change updated a number of docstrings within the codebase to use standardised `black` code formatting, but a couple of locations had been missed.

### Checklist

This pull request is:

- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed

Closes: #1228
Pull-request: https://github.com/sqlalchemy/alembic/pull/1228
Pull-request-sha: f5696b9ca34998e22af5705434ed2393d86e82c0

Change-Id: I5d935b036d6f4e11eb5c229f9982db587d67ae24

2 years agoConsistency: apply codestyle formatting to docstring code snippets
James Addison [Thu, 13 Apr 2023 19:11:01 +0000 (15:11 -0400)] 
Consistency: apply codestyle formatting to docstring code snippets

### Description
This is a pedantic/consistency follow-up from #1219: that change applied some `black` formatting to two code snippets, and this change applies that formatting to the remaining snippets in the codebase.

For each snippet, I extracted the code and applied formatting using `black` v23.1.0, then placed the results back into the source.

In one case there was an associated 'output' block, and in that case I re-ran the snippet code to update the results of that output too (this included a [change-in-output](https://github.com/sqlalchemy/alembic/compare/main...openculinary:alembic:docstrings/snippet-format-consistency?expand=1#diff-bf4756660cdb31ee8566a2cff72526671356c38a725195723ce0e65e6c11e6cfR124) thanks to a [bugfix since the snippet was written](https://github.com/sqlalchemy/alembic/commit/bc6971aa4abdafb7e1a1123c26a373cc25a34ca9), by the looks of it).

### Checklist

This pull request is:

- [x] A documentation / typographical error fix

Closes: #1220
Pull-request: https://github.com/sqlalchemy/alembic/pull/1220
Pull-request-sha: cd65a453192546a660d6f5ebad5af08bb1c72af4

Change-Id: I6758445633c364c8fb2f4d8376d83607430a36d6

2 years agoMerge "Improve typing." into main
mike bayer [Tue, 25 Apr 2023 16:42:38 +0000 (16:42 +0000)] 
Merge "Improve typing." into main

2 years agoReplace find with find_namespace in setuptools config.
Federico Caselli [Mon, 24 Apr 2023 20:26:38 +0000 (22:26 +0200)] 
Replace find with find_namespace in setuptools config.

This removes a warning from setuptools

Fixes: #1227
Change-Id: I81187e86038836ded39140076f25dc5f6bc1eb35

2 years agorename upload-dir to upload_dir to silence setuptool warning
Federico Caselli [Mon, 24 Apr 2023 20:09:18 +0000 (22:09 +0200)] 
rename upload-dir to upload_dir to silence setuptool warning

Change-Id: I048cc0653de1b7885665b747cceb083d348f7f18

2 years agoadd missing tag to 1.10.4 changelog
Federico Caselli [Mon, 24 Apr 2023 19:33:13 +0000 (21:33 +0200)] 
add missing tag to 1.10.4 changelog

Change-Id: Ifbec22c07ce887f4e25d25ad47aff44dcbae366b

2 years agoVersion 1.10.5 placeholder
Mike Bayer [Mon, 24 Apr 2023 15:12:43 +0000 (11:12 -0400)] 
Version 1.10.5 placeholder

2 years ago- 1.10.4 rel_1_10_4
Mike Bayer [Mon, 24 Apr 2023 15:08:10 +0000 (11:08 -0400)] 
- 1.10.4

2 years agoImprove typing.
Federico Caselli [Thu, 13 Apr 2023 20:22:14 +0000 (22:22 +0200)] 
Improve typing.

Correctly pass previously ignored arguments ``insert_before`` and
``insert_after`` in ``batch_alter_column``

Fixes: #1221
Change-Id: I79c9144f3e521fca00a0c32462ae2a69f9f7a032

2 years agoFix type annotation in `op.create_table_comment`
Colin Adams [Thu, 13 Apr 2023 19:24:41 +0000 (15:24 -0400)] 
Fix type annotation in `op.create_table_comment`

### Description

The `existing_comment` parameter had type `None`, but it should be `Optional[str]`.

Fixes #903

### Checklist

This pull request is:

- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] 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: #1115
Pull-request: https://github.com/sqlalchemy/alembic/pull/1115
Pull-request-sha: 973ca93b199dccf4474db650bcfee797b2bf7c51

Change-Id: Ic4a25e320fe3e4578e3df9aea689d760844c055e

2 years agotooling: write_pyi.py: filter usage of raw-strings (rstrings)
James Addison [Mon, 10 Apr 2023 19:40:38 +0000 (15:40 -0400)] 
tooling: write_pyi.py: filter usage of raw-strings (rstrings)

### Description
While reading the diff between [`rel_1_10_2...rel_1_10_3`](https://github.com/sqlalchemy/alembic/compare/rel_1_10_2...rel_1_10_3), the introduction of r-strings drew my attention, and that resulted in some [discussion on the relevant commit](https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33).

This changeset filters the production of r-strings during stub-generation to cases where docstrings contain escape (backslash, `\`) characters.

I'll admit that I didn't realize until today that these stubs are primarily for typechecking.  Since that's the case, I have doubts about whether the change is worthwhile (consistency and simplicity -- using r-strings for all docstrings in the stubs -- even if it's redundant, seems fine to me).

### Checklist
This pull request is:

- [x] A documentation / typographical error fix
- [x] A short code fix
- Relates to discussion at https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33

Closes: #1218
Pull-request: https://github.com/sqlalchemy/alembic/pull/1218
Pull-request-sha: 352ab8829525435f78838687e12156a3fa3a3d86

Closes: #1219
Pull-request: https://github.com/sqlalchemy/alembic/pull/1219
Change-Id: I2808a592681dabc093d538f589e673fcc5e05822

2 years agoMerge "Use column sort in index compare on postgresql" into main
mike bayer [Mon, 10 Apr 2023 21:01:11 +0000 (21:01 +0000)] 
Merge "Use column sort in index compare on postgresql" into main

2 years agoUse column sort in index compare on postgresql
CaselIT [Thu, 6 Apr 2023 20:16:41 +0000 (22:16 +0200)] 
Use column sort in index compare on postgresql

Added support for autogenerate comparison of indexes on PostgreSQL which
include SQL sort option, such as ``ASC`` or ``NULLS FIRST``.

Fixes: #1213
Change-Id: I3ddcb647928d948e41462b1c889b1cbb515ace4f

2 years agouniquify cols for FK table object
Mike Bayer [Fri, 7 Apr 2023 15:05:20 +0000 (11:05 -0400)] 
uniquify cols for FK table object

Fixed issue where using a directive such as ``op.create_foreign_key()`` to
create a self-referential constraint on a single table where the same
column were present on both sides (e.g. within a composite foreign key)
would produce an error under SQLAlchemy 2.0 and a warning under SQLAlchemy
1.4 indicating that a duplicate column were being added to a table.

Change-Id: I2a8f5d8def2714792bffcdfb8bf88a5080ec8ce7
Fixes: #1215
2 years agoVersion 1.10.4 placeholder
Mike Bayer [Wed, 5 Apr 2023 19:40:58 +0000 (15:40 -0400)] 
Version 1.10.4 placeholder

2 years ago- 1.10.3 rel_1_10_3
Mike Bayer [Wed, 5 Apr 2023 19:39:34 +0000 (15:39 -0400)] 
- 1.10.3

2 years agoMerge "Fix issues in autogenerate of function index removal" into main
mike bayer [Tue, 4 Apr 2023 14:51:51 +0000 (14:51 +0000)] 
Merge "Fix issues in autogenerate of function index removal" into main

2 years agoMerge "Fix type annotation for `url`" into main
mike bayer [Mon, 3 Apr 2023 23:00:40 +0000 (23:00 +0000)] 
Merge "Fix type annotation for `url`" into main

2 years agoFix issues in autogenerate of function index removal
CaselIT [Mon, 3 Apr 2023 21:15:45 +0000 (23:15 +0200)] 
Fix issues in autogenerate of function index removal

Fixed error raised by alembic when running autogenerate after removing
a function based index.

Fixes: #1212
Change-Id: Idc565d661229afda89d44e36786bb0357323e604

2 years agoFix type annotation for `url`
Viicos [Sun, 26 Mar 2023 02:02:22 +0000 (22:02 -0400)] 
Fix type annotation for `url`

<!-- Provide a general summary of your proposed changes in the Title field above -->
Left the `pyi` generated file untouched.
### Description
<!-- Describe your changes in detail -->

### 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:

- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] 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: #1209
Pull-request: https://github.com/sqlalchemy/alembic/pull/1209
Pull-request-sha: d15cb6e28d5bb934d139ced87e713a9d77505346

Change-Id: I8548806a693b150f1417a102e6498119524008a0

2 years agoAdd docs for data migrations
Vlastimil Zíma [Sat, 4 Jun 2022 14:28:36 +0000 (10:28 -0400)] 
Add docs for data migrations

### Description
I added a small docs regarding data migrations, based on #972.

### 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:

- [X] A documentation / typographical error fix
- Good to go, no issue or tests are needed

**Have a nice day!**

Closes: #1040
Pull-request: https://github.com/sqlalchemy/alembic/pull/1040
Pull-request-sha: c985e0d8096e750df35aa07dde71f432a57656b6

Change-Id: Icf6fdb1089eb7c386dad4401b99caaddc352d92f

2 years agoFix unknown types reported by pyright
CaselIT [Mon, 6 Mar 2023 21:15:15 +0000 (22:15 +0100)] 
Fix unknown types reported by pyright

Fixed various typing issues observed with pyright, including issues
involving the combination of :class:`.Function` and
:meth:`.MigrationContext.begin_transaction`.

Fixes: #1191
Fixes: #1201
Change-Id: I9856a8f59c22130c8bbcbed3e19cf2e8a8bf0608

2 years agoVersion 1.10.3 placeholder
Mike Bayer [Wed, 8 Mar 2023 17:18:10 +0000 (12:18 -0500)] 
Version 1.10.3 placeholder

2 years ago- 1.10.2 rel_1_10_2
Mike Bayer [Wed, 8 Mar 2023 17:16:40 +0000 (12:16 -0500)] 
- 1.10.2

2 years agomock _NONE_NAME for < 1.3.24
Mike Bayer [Tue, 7 Mar 2023 16:07:33 +0000 (11:07 -0500)] 
mock _NONE_NAME for < 1.3.24

Fixed regression where Alembic would not run with older SQLAlchemy 1.3
versions prior to 1.3.24 due to a missing symbol. Workarounds have been
applied for older 1.3 versions.

Change-Id: Ie7b5f6295e55276f0e912bf2b10b8c96dad171b9
Fixes: #1196
2 years agoVersion 1.10.2 placeholder
Mike Bayer [Tue, 7 Mar 2023 01:14:59 +0000 (20:14 -0500)] 
Version 1.10.2 placeholder

2 years ago- 1.10.1 rel_1_10_1
Mike Bayer [Tue, 7 Mar 2023 01:12:57 +0000 (20:12 -0500)] 
- 1.10.1

2 years agoMerge "improve autogen rendering for PG ExcludeConstraint" into main
mike bayer [Tue, 7 Mar 2023 01:11:33 +0000 (01:11 +0000)] 
Merge "improve autogen rendering for PG ExcludeConstraint" into main

2 years agoimprove autogen rendering for PG ExcludeConstraint
Jan Katins [Mon, 6 Mar 2023 21:18:17 +0000 (16:18 -0500)] 
improve autogen rendering for PG ExcludeConstraint

Fixed issue regarding PostgreSQL :class:`.ExcludeConstraint`, where
constraint elements which made use of :func:`.literal_column` could not be
rendered for autogenerate. Additionally, using SQLAlchemy 2.0.5 or greater,
:func:`.text()` constructs are also supported within PostgreSQL
:class:`.ExcludeConstraint` objects for autogenerate render. Pull request
courtesy Jan Katins.

Fixes: #1184
Closes: #1185
Pull-request: https://github.com/sqlalchemy/alembic/pull/1185
Pull-request-sha: 68360ce9aa746a85407c5e1e04b8021123d98504

Change-Id: I302f3f4007a186ffac13b344ff6769dd302f28f5

2 years agodistinguish between string contraint name and defined
Mike Bayer [Mon, 6 Mar 2023 18:34:40 +0000 (13:34 -0500)] 
distinguish between string contraint name and defined

Take _NONE_NAME into account as a valid constraint name
and don't skip these constraints or consider them to be unnamed.
Thanks to typing this also revealed that previous batch versions
were also keying "_NONE_NAME" constraints as though they were named.

Fixed regression for 1.10.0 where :class:`.Constraint` objects were
suddenly required to have non-None name fields when using batch mode, which
was not previously a requirement.

Change-Id: If4a7191a00848b19cb124bc6da362f3bc6ce1472
Fixes: #1195
2 years agoVersion 1.10.1 placeholder
Mike Bayer [Sun, 5 Mar 2023 23:12:18 +0000 (18:12 -0500)] 
Version 1.10.1 placeholder

2 years ago- 1.10.0 rel_1_10_0
Mike Bayer [Sun, 5 Mar 2023 23:06:04 +0000 (18:06 -0500)] 
- 1.10.0

2 years agochangelog updates
Mike Bayer [Sun, 5 Mar 2023 23:05:24 +0000 (18:05 -0500)] 
changelog updates

Change-Id: I2c796e4120a4674a46f4ebedbf63d9e40ebe49b9

2 years agoUpdate example to sqlalchemy 2 (#1171)
Sam Bull [Wed, 1 Mar 2023 21:54:49 +0000 (21:54 +0000)] 
Update example to sqlalchemy 2 (#1171)

2 years agoFixes test in older sqlite
CaselIT [Wed, 1 Mar 2023 21:49:33 +0000 (22:49 +0100)] 
Fixes test in older sqlite

Change-Id: I2f816a37abf7fa3203879e1d03b55307bd957ee4

2 years agoMerge "Improved support for expression indexes" into main
mike bayer [Wed, 1 Mar 2023 21:28:01 +0000 (21:28 +0000)] 
Merge "Improved support for expression indexes" into main

2 years agoMerge "Improve typing to accommodate sqlalchemy v2" into main
mike bayer [Wed, 1 Mar 2023 21:27:09 +0000 (21:27 +0000)] 
Merge "Improve typing to accommodate sqlalchemy v2" into main

2 years agoMerge "add recursive_version_locations option for searching revision files" into...
mike bayer [Wed, 1 Mar 2023 21:26:15 +0000 (21:26 +0000)] 
Merge "add recursive_version_locations option for searching revision files" into main

2 years agoMerge "set next version at 1.10.0" into main
mike bayer [Wed, 1 Mar 2023 21:26:06 +0000 (21:26 +0000)] 
Merge "set next version at 1.10.0" into main

2 years agoadd recursive_version_locations option for searching revision files
ostr00000 [Mon, 27 Feb 2023 23:18:19 +0000 (18:18 -0500)] 
add recursive_version_locations option for searching revision files

Recursive traversal of revision files in a particular revision directory is
now supported, by indicating ``recursive_version_locations = true`` in
alembic.ini. Pull request courtesy ostr00000.

Fixes: #760
Closes: #1182
Pull-request: https://github.com/sqlalchemy/alembic/pull/1182
Pull-request-sha: ecb0da48b459abd3f5e95390ec7030a7e3fcbc6d

Change-Id: I711ca2dbd35fb9a2acdbfd374bcac13043b0d129

2 years agoEscape sql server constriant names
CaselIT [Thu, 23 Feb 2023 20:45:11 +0000 (21:45 +0100)] 
Escape sql server constriant names

Properly escape constraint name on SQL Server when dropping
a column while specifying ``mssql_drop_default=True`` or
``mssql_drop_check=True`` or ``mssql_drop_foreign_key=True``.

Fixes: #1187
Change-Id: I060442bc63c4e53f64724985e20e6e15e4335b6b

2 years agoensure single import per line
Mike Bayer [Tue, 28 Feb 2023 15:58:22 +0000 (10:58 -0500)] 
ensure single import per line

This adds the very small plugin flake8-import-single which
will prevent us from having an import with more than one symbol
on a line.

Flake8 by itself prevents this pattern with E401:

   import collections, os, sys

However does not do anything with this:

   from sqlalchemy import Column, text

Both statements have the same issues generating merge artifacts
as well as presenting a manual decision to be made.   While
zimports generally cleans up such imports at the top level, we
don't enforce zimports / pre-commit use.

the plugin finds the same issue for imports that are inside of
test methods.   We shouldn't usually have imports in test methods
so most of them here are moved to be top level.

The version is pinned at 0.1.5; the project seems to have no
activity since 2019, however there are three 0.1.6dev releases
on pypi which stopped in September 2019, they seem to be
experiments with packaging.  The source for 0.1.5
is extremely simple and only reveals one method to flake8
(the run() method).

Change-Id: Icea894e43bad9c0b5d4feb5f49c6c666d6ea6aa1

2 years agoImproved support for expression indexes
CaselIT [Sat, 4 Feb 2023 12:28:42 +0000 (13:28 +0100)] 
Improved support for expression indexes

Added support for autogenerate comparison of indexes on PostgreSQL which
include SQL expressions; the previous warning that such indexes were
skipped is now removed. This functionality requires SQLAlchemy 2.0.
For older SQLAlchemy versions, these indexes are still skipped.

Fixed issue where indexes on SQLite which include SQL expressions would not
compare against themselves correctly, generating false positives.
SQLAlchemy as of version 2 has no support for reflecting expression based
indexes on SQLite; so for now, the behavior is that SQLite expression-based
indexes are ignored for autogenerate compare, in the same way that
PostgreSQL expression-based indexes were ignored for the time that
SQLAlchemy did not support reflection of such indexes (which is now
supported in SQLAlchemy 2.0 as well as this release of Alembic).

Fixed issue in index detection where autogenerate change detection would
consider indexes with the same columns but with different order as equal,
while in general they are not equivalent in how a database will use them.

Fixes: #1165
Fixes: #1166
Change-Id: I226408eed855b923172e5df0bdab005ed2cc9f53

2 years agoImprove typing to accommodate sqlalchemy v2
CaselIT [Fri, 10 Feb 2023 21:24:11 +0000 (22:24 +0100)] 
Improve typing to accommodate sqlalchemy v2

Index name can be null.

Fixes: #1168
Change-Id: Id7c944e19a9facd7d3862d43f84fd70aedace999

2 years agoset next version at 1.10.0
Mike Bayer [Sun, 26 Feb 2023 01:06:42 +0000 (20:06 -0500)] 
set next version at 1.10.0

Will rebase current 1.10 gerrits to this one until we are
very close to 1.10 issues being very close to ready for release.
In the interim, I'd rather not have an 0.9 branch for emergency
bugfixes.

We are mostly here waiting on I226408eed855b923172e5df0bdab005ed2cc9f53
for 1.10 to be close to release.

Change-Id: I9b568a19d6653ed54069b84187dcb10ad4150274

2 years agoUpdate docstring to suggest raw string (#1186)
Tim Penhey [Thu, 23 Feb 2023 21:17:57 +0000 (10:17 +1300)] 
Update docstring to suggest raw string (#1186)

* Update docstring to suggest raw string

When escaping the `:` for `op.execute` if a normal string is used, you need to escape the backslash, eg. `'\\:colon_value'` or using a raw string.
For the docs I feel it is nicer to show the raw string.

* Update stub documentation

Change-Id: Ia605c6c036fe82cebff9b427333404f1c59ea74d

---------

Co-authored-by: CaselIT <cfederico87@gmail.com>
2 years agoVersion 1.9.5 placeholder
Mike Bayer [Thu, 16 Feb 2023 17:38:03 +0000 (12:38 -0500)] 
Version 1.9.5 placeholder

2 years ago- 1.9.4 rel_1_9_4
Mike Bayer [Thu, 16 Feb 2023 17:35:31 +0000 (12:35 -0500)] 
- 1.9.4

2 years agoMerge "dont use server_default render_item for SQL compare" into main
mike bayer [Thu, 16 Feb 2023 15:10:29 +0000 (15:10 +0000)] 
Merge "dont use server_default render_item for SQL compare" into main

2 years agoMerge "collapse all chars for mssql defaults, move quoting" into main
mike bayer [Thu, 16 Feb 2023 15:10:23 +0000 (15:10 +0000)] 
Merge "collapse all chars for mssql defaults, move quoting" into main

2 years agodont use server_default render_item for SQL compare
Mike Bayer [Thu, 16 Feb 2023 02:34:30 +0000 (21:34 -0500)] 
dont use server_default render_item for SQL compare

Removed a mis-use of the
:paramref:`.EnvironmentContext.configure.render_item` callable where the
"server_default" renderer would be erroneously used within the server
default comparison process, which is working against SQL expressions, not
Python code.

Change-Id: Id6fad1e6f5ac0a68bbd0e6b7e6088e451bf6dc2b
References: #641
Fixes: #1180
2 years agoMerge "restore config object to merge command" into main
mike bayer [Wed, 15 Feb 2023 18:22:05 +0000 (18:22 +0000)] 
Merge "restore config object to merge command" into main

2 years agocollapse all chars for mssql defaults, move quoting
Mike Bayer [Tue, 14 Feb 2023 17:45:24 +0000 (12:45 -0500)] 
collapse all chars for mssql defaults, move quoting

Ongoing fixes for SQL Server server default comparisons under autogenerate,
adjusting for SQL Server's collapsing of whitespace between SQL function
arguments when reporting on a function-based server default, as well as its
arbitrary addition of parenthesis within arguments; the approach has now
been made more aggressive by stripping the two default strings to compare
of all whitespace, parenthesis, and quoting characters.

Fixed PostgreSQL server default comparison to handle SQL expressions
sent as ``text()`` constructs, such as ``text("substring('name', 1, 3)")``,
which previously would raise errors when attempting to run a server-based
comparison.

Change-Id: Icd861f62653fc7b3900164c0d047821125e1305e
Fixes: #1177
2 years agoFollow up Ia98c8f9a93953f049378f5029e355a3f249ed638
CaselIT [Tue, 14 Feb 2023 20:52:33 +0000 (21:52 +0100)] 
Follow up Ia98c8f9a93953f049378f5029e355a3f249ed638
that was merged prematurely

Change-Id: I131dfb8dabf10457954f5216b1abadc976aebd38

2 years agorestore config object to merge command
Brendan Gann [Tue, 14 Feb 2023 16:03:09 +0000 (11:03 -0500)] 
restore config object to merge command

Fixed regression introduced in 1.7.0 where the "config" object passed to
the template context when running the :func:`.merge` command
programmatically failed to be correctly populated. Pull request courtesy
Brendan Gann.

Closes: #1176
Pull-request: https://github.com/sqlalchemy/alembic/pull/1176
Pull-request-sha: cf6a886915f6bef6eeef8041804e316038955402

Change-Id: Idbab2dc0339cce6f8827d2f49156791600a82c1a

2 years agoMerge "Update annotation to allow PathLike" into main
mike bayer [Tue, 14 Feb 2023 15:46:06 +0000 (15:46 +0000)] 
Merge "Update annotation to allow PathLike" into main

2 years agoInclude missing part of env.py
Sam Bull [Mon, 13 Feb 2023 20:36:06 +0000 (15:36 -0500)] 
Include missing part of env.py

This part is missing from the example, and if a user started with the async template, then they would have an `asyncio.run()` call in here, which breaks the script.

Fixes: #1174
Closes: #1172
Pull-request: https://github.com/sqlalchemy/alembic/pull/1172
Pull-request-sha: fa2c55319d09fab4e1435433fa2d7e5fca5dc820

Change-Id: Ia98c8f9a93953f049378f5029e355a3f249ed638

2 years agoUpdate annotation to allow PathLike
Sam Bull [Mon, 13 Feb 2023 20:57:29 +0000 (15:57 -0500)] 
Update annotation to allow PathLike

The value is only used in os.path.abspath(), so it works fine with Path.

Closes: #1173
Pull-request: https://github.com/sqlalchemy/alembic/pull/1173
Pull-request-sha: 7cf9606602bb5692ddeb3551500be0dd956bd5d9

Change-Id: Ic629a7290464291377d066e856a8ae8a3f6505bc

2 years agouse correct param name
Mike Bayer [Mon, 13 Feb 2023 14:00:29 +0000 (09:00 -0500)] 
use correct param name

Change-Id: I2981335a5deaa798195cfe70f3655d79cd4d8a3b

2 years agopin sphinx-copybutton and change config
Mike Bayer [Thu, 9 Feb 2023 17:11:31 +0000 (12:11 -0500)] 
pin sphinx-copybutton and change config

sphinx-copybutton introduced a new feature
in 0.5.1 which includes a default configuration
that breaks the regexp prompt matching scheme.

set copybutton_exclude to not include ".gp" as that's the class
where we exactly look for the prompts we are matching.

pin sphinx-copybutton at 0.5.1 to avoid future problems.

Change-Id: Ie03bc27a9190e71b63fc68b484f23e53b8cb72dc
References: https://github.com/executablebooks/sphinx-copybutton/issues/185

2 years agoVersion 1.9.4 placeholder
Mike Bayer [Tue, 7 Feb 2023 20:48:43 +0000 (15:48 -0500)] 
Version 1.9.4 placeholder

2 years ago- 1.9.3 rel_1_9_3
Mike Bayer [Tue, 7 Feb 2023 20:47:07 +0000 (15:47 -0500)] 
- 1.9.3

2 years agoadd variant render step for user-defined types
Mike Bayer [Tue, 7 Feb 2023 04:30:58 +0000 (23:30 -0500)] 
add variant render step for user-defined types

due to SQLA 2.0's variant being integrated into types,
the variant rendering conditional would no longer take effect
as the type was not under the "sqlalchemy" module namespace.

Fixed issue where rendering of user-defined types that then went onto use
the ``.with_variant()`` method would fail to render, if using SQLAlchemy
2.0's version of variants.

Change-Id: I3c6f14325d6dffb2ddc1bf955753ee5a2de2cedd
Fixes: #1167