sqlalchemy / alembic

A database migrations tool for SQLAlchemy.
MIT License
2.61k stars 234 forks source link

script_location PATH config is not OS agnostic #1431

Closed developer992 closed 4 months ago

developer992 commented 4 months ago

Describe the bug This setting is different if you are running on Windows OS or Linux OS

script_location = app/db/migrations

Expected behavior I am developing on Windows machine and i set the value of the setting to "app\db\migrations"

But then I build docker image, deploy and want to run it the server and I have to fix the config file to "app/db/migrations"

I find myself changing this quite frequently, is there a way to define this with mutli OS support in mind?

Thanks

To Reproduce Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved. See also Reporting Bugs on the website.

# Insert code here

Error

# Copy error here. Please include the full stack trace.

Versions.

Additional context

Have a nice day!

CaselIT commented 4 months ago

Hi,

Does using / on windows not work?

developer992 commented 4 months ago

no it fails with


FAILED: Path doesn't exist: '/app/xara\\db\\migrations'.  Please use the 'init' command to create a new scripts
  folder.
˙˙˙`
CaselIT commented 4 months ago

that seems an absolute path, is that what you wanted to use?

developer992 commented 4 months ago

I have the setting in relative path but this is what running "alembic upgrade head" outputs

CaselIT commented 4 months ago

I can't reproduce.

I've just tried the following:

> systeminfo | rg 'OS Name'
OS Name:                   Microsoft Windows 11 Pro
> rg script_location .\alembic.ini
5:script_location = foo/bar/baz/migrations
> alembic history
<base> -> baaccf72950c (head), one
> ls .

    Directory: path\to\here

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          27/02/2024    20:48                foo
-a---          27/02/2024    20:49           3647 alembic.ini
-a---          27/02/2024    20:49          24576 db.sqlite
developer992 commented 4 months ago

hm ok thta's good news, thanks ...

maybe different powershell version?

> pwsh -v
PowerShell 7.4.1
CaselIT commented 4 months ago

I don't think it's something that has to do with powershell, since the path is never handled by the shell since it's in the alembic file that's read by python.

Can you create a reproducing case for the error you are seeing?