Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql default for column "alpn" cannot be cast automatically to type temp_alpn #1556

Open
zax2002 opened this issue Jan 2, 2025 · 1 comment

Comments

@zax2002
Copy link

zax2002 commented Jan 2, 2025

Describe the bug
SQLALCHEMY_DATABASE_URL = "postgresql+psycopg2://postgres:password@localhost:5432/marzban"

When I run docker-compose up with empty database, I get this error:

...
marzban_1  | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
marzban_1  | INFO  [alembic.runtime.migration] Will assume transactional DDL.
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade  -> 94a5cc12c0d6, init user table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 94a5cc12c0d6 -> 3cf36a5fde73, init system table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 3cf36a5fde73 -> 9d5a518ae432, init jwt table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 9d5a518ae432 -> 9b60be6cd0a2, add created_at field to users table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 9b60be6cd0a2 -> 8e849e06f131, proxy table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 8e849e06f131 -> 671621870b02, init admin
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 671621870b02 -> e91236993f1a, inbounds table & excluded_inbounds
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade e91236993f1a -> b3378dc6de01, hosts
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 671621870b02 -> d02dcfbf1517, add UserUsageResetLogs Model and data_limit_strategy field to user
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade d02dcfbf1517, b3378dc6de01 -> ece13c4c6f65, empty message
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade ece13c4c6f65 -> b15eba6e5867, add host and sni columns to hosts table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade b15eba6e5867 -> 51e941ed9018, deactive user status
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 51e941ed9018 -> e3f0e888a563, rename deactive status to disabled
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade e3f0e888a563 -> 7cbe9d91ac11, ProxyHost: security added
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 7cbe9d91ac11 -> 5b84d88804a1, fix
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 5b84d88804a1 -> a0d3d400ea75, Admin: is_sudo field
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 5b84d88804a1 -> fad8b1997c3a, case insensitive username
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade fad8b1997c3a, a0d3d400ea75 -> e410e5f15c3f, merge fad8b1997c3a & a0d3d400ea75
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade e410e5f15c3f -> 97dd9311ab93, add user templates
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 97dd9311ab93 -> 37692c1c9715, nodes
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 37692c1c9715 -> e4a86bc8ec7b, node_user_usages
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade e4a86bc8ec7b -> 57fda18cd9e6, add xray version
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 57fda18cd9e6 -> c106bb40c861, alpn_fingerprint_hosts
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade c106bb40c861 -> fc01b1520e72, add node usages
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade fc01b1520e72 -> 35f7f8fa9cf2, add sub_revoked_at to users
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 35f7f8fa9cf2 -> c47250b790eb, add user note
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade c47250b790eb -> 015cf1dc6eca, sub_updated_at and sub_last_user_agent
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 015cf1dc6eca -> a6e3fff39291, add notification reminders
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade a6e3fff39291 -> 025d427831dd, sub_last_user_agent length
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 025d427831dd -> 1cf7d159fdbb, add online at
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 1cf7d159fdbb -> a0715c2615f0, Add allow in secure and disable host
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade a0715c2615f0 -> 77c86a261126, Nodes coefficient
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 77c86a261126 -> 7a0dbb8a2f65, init tls table
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 7a0dbb8a2f65 -> fe7796f840a4, remove certficiate from nodes
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 77c86a261126 -> 5a4446e7b165, add password_reset_at to admins
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 5a4446e7b165, fe7796f840a4 -> 0f720f5c54dd, empty message
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 0f720f5c54dd -> 08b381fc1bc7, update_shadowsocks_method
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 08b381fc1bc7 -> 947ebbd8debe, Add on hold
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 947ebbd8debe -> 714f227201a7, Fix User Template
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 714f227201a7 -> e56f1c781e46, Fix on hold
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade e56f1c781e46 -> 470465472326, add path to hosts
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 470465472326 -> 5575fe410515, add_telegram_id_to_admin
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 5575fe410515 -> dd725e4d3628, fix_mysql_collations
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade dd725e4d3628 -> adda2dd4a741, Add sockopt proxy_outbound mux_enable fragment_setting to hosts
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade dd725e4d3628 -> 852d951c9c08, drop_extra_index
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 852d951c9c08, adda2dd4a741 -> 1ad79b97fdcf, empty message
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 1ad79b97fdcf -> 4f045f53bef8, drop proxy_outbound and sockopt from hosts
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 4f045f53bef8 -> ccbf9d322ae3, user_auto_delete_in_days
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade ccbf9d322ae3 -> 07f9bbb3db4e, user_last_status_change
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 4f045f53bef8 -> 31f92220c0d0, Add Support Random User-Agent
marzban_1  | INFO  [alembic.runtime.migration] Running upgrade 31f92220c0d0 -> 305943d779c4, add h3 to alpn enum
marzban_1  | Traceback (most recent call last):
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
marzban_1  |     self.dialect.do_execute(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
marzban_1  |     cursor.execute(statement, parameters)
marzban_1  | psycopg2.errors.DatatypeMismatch: default for column "alpn" cannot be cast automatically to type temp_alpn
marzban_1  | 
marzban_1  | 
marzban_1  | The above exception was the direct cause of the following exception:
marzban_1  | 
marzban_1  | Traceback (most recent call last):
marzban_1  |   File "/usr/local/bin/alembic", line 8, in <module>
marzban_1  |     sys.exit(main())
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 590, in main
marzban_1  |     CommandLine(prog=prog).main(argv=argv)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 584, in main
marzban_1  |     self.run_cmd(cfg, options)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/config.py", line 561, in run_cmd
marzban_1  |     fn(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 322, in upgrade
marzban_1  |     script.run_env()
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 569, in run_env
marzban_1  |     util.load_python_file(self.dir, "env.py")
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
marzban_1  |     module = load_module_py(module_id, path)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
marzban_1  |     spec.loader.exec_module(module)  # type: ignore
marzban_1  |   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
marzban_1  |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
marzban_1  |   File "/code/app/db/migrations/env.py", line 82, in <module>
marzban_1  |     run_migrations_online()
marzban_1  |   File "/code/app/db/migrations/env.py", line 76, in run_migrations_online
marzban_1  |     context.run_migrations()
marzban_1  |   File "<string>", line 8, in run_migrations
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/runtime/environment.py", line 853, in run_migrations
marzban_1  |     self.get_context().run_migrations(**kw)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/runtime/migration.py", line 623, in run_migrations
marzban_1  |     step.migration_fn(**kw)
marzban_1  |   File "/code/app/db/migrations/versions/305943d779c4_add_h3_to_alpn_enum.py", line 51, in upgrade
marzban_1  |     with op.batch_alter_table(table_name) as batch_op:
marzban_1  |   File "/usr/local/lib/python3.10/contextlib.py", line 142, in __exit__
marzban_1  |     next(self.gen)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/operations/base.py", line 381, in batch_alter_table
marzban_1  |     impl.flush()
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/operations/batch.py", line 111, in flush
marzban_1  |     fn(*arg, **kw)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/ddl/postgresql.py", line 159, in alter_column
marzban_1  |     self._exec(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 195, in _exec
marzban_1  |     return conn.execute(construct, multiparams)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
marzban_1  |     return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
marzban_1  |     return connection._execute_ddl(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
marzban_1  |     ret = self._execute_context(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
marzban_1  |     self._handle_dbapi_exception(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
marzban_1  |     util.raise_(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 210, in raise_
marzban_1  |     raise exception
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
marzban_1  |     self.dialect.do_execute(
marzban_1  |   File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
marzban_1  |     cursor.execute(statement, parameters)
marzban_1  | sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) default for column "alpn" cannot be cast automatically to type temp_alpn
marzban_1  | 
marzban_1  | [SQL: ALTER TABLE hosts ALTER COLUMN alpn TYPE temp_alpn USING alpn::text::temp_alpn]

Machine details (please complete the following information):

  • OS: Ubuntu 24.04
  • PostgreSQL: 13.5
  • docker-compose: 1.29.2
  • Marzban: release v0.7.0
@M03ED
Copy link
Collaborator

M03ED commented Jan 2, 2025

Currently there is no postgresql support in marzban
You can help and add it
Pr Welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants