Jie211 opened a new issue, #60863:
URL: https://github.com/apache/airflow/issues/60863

   ### Apache Airflow Provider(s)
   
   fab
   
   ### Versions of Apache Airflow Providers
   
   ```
   apache-airflow-providers-amazon==9.19.0
   apache-airflow-providers-apache-cassandra==3.9.0
   apache-airflow-providers-apache-hdfs==4.11.1
   apache-airflow-providers-apache-hive==9.2.2
   apache-airflow-providers-apache-livy==4.5.1
   apache-airflow-providers-apache-spark==5.4.2
   apache-airflow-providers-celery==3.15.0
   apache-airflow-providers-cncf-kubernetes==10.12.0
   apache-airflow-providers-common-compat==1.11.0
   apache-airflow-providers-common-io==1.7.0
   apache-airflow-providers-common-sql==1.30.2
   apache-airflow-providers-fab==3.1.1
   apache-airflow-providers-git==0.2.0
   apache-airflow-providers-github==2.10.1
   apache-airflow-providers-http==5.6.2
   apache-airflow-providers-mysql==6.4.0
   apache-airflow-providers-odbc==4.11.0
   apache-airflow-providers-openai==1.7.1
   apache-airflow-providers-openlineage==2.9.2
   apache-airflow-providers-opensearch==1.8.2
   apache-airflow-providers-oracle==4.3.0
   apache-airflow-providers-pagerduty==5.2.1
   apache-airflow-providers-papermill==3.12.0
   apache-airflow-providers-postgres==6.5.1
   apache-airflow-providers-redis==4.4.1
   apache-airflow-providers-slack==9.6.1
   apache-airflow-providers-smtp==2.4.1
   apache-airflow-providers-ssh==4.2.1
   apache-airflow-providers-standard==1.10.2
   apache-airflow-providers-tableau==5.3.1
   apache-airflow-providers-trino==6.4.1
   
   ```
   
   ### Apache Airflow version
   
   3.1.6
   
   ### Operating System
   
   Rocky Linux 9.7
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   - Customized Helm Chart which is base on Official Helm Chart.
   - Database: PostgreSQL
   
   ### What happened
   
   When creating a new Airflow 3.1.6 cluster with FAB auth manager configured, 
the ab_user table is created with first_name and last_name columns having 
VARCHAR(64) instead of the expected VARCHAR(256).
   (It’s possible other columns have issues too...I didn’t check everything)
   
   1. FABDBManager.create_db_from_orm() was updated in FAB provider 3.1.1 to 
call db.create_all() 
(https://github.com/apache/airflow/commit/af2bd2671ddf67fc93ad433f4172dc55f738c03b#diff-edf4420ebe0d73a3987a6ac5c07f47eae797b080baddd76ad3be0c4dc2d02222R61-R63)
   2. The ORM model in airflow/providers/fab/auth_manager/models/__init__.py 
defines:
   ```
     first_name: Mapped[str] = mapped_column(String(64), nullable=False)
     last_name: Mapped[str] = mapped_column(String(64), nullable=False)
   ```
   
https://github.com/apache/airflow/blob/providers-fab/3.1.2/providers/fab/src/airflow/providers/fab/auth_manager/models/__init__.py#L238-L239
   3. But the migration file 0001_1_4_0_create_ab_tables_if_missing.py defines:
   ```
     sa.Column("first_name", sa.String(length=256), nullable=False),
     sa.Column("last_name", sa.String(length=256), nullable=False),
   ```
   
https://github.com/apache/airflow/blob/providers-fab/3.1.2/providers/fab/src/airflow/providers/fab/migrations/versions/0000_1_4_0_create_ab_tables_if_missing.py#L94-L95
   4. When initdb() runs on a fresh database, it calls create_db_from_orm() 
which creates tables using ORM metadata (String(64)), then stamps alembic 
version as "head". The migration is never executed because tables already exist 
with if_not_exists=True. 
   
   ### What you think should happen instead
   
   The ORM model and migration file should have consistent column definitions. 
   After run `airflow db migration`, the first_name and last_name columns in 
both User and RegisterUser models should be String(256) to match the migration 
file.
   
   ### How to reproduce
   
   1. Set up a fresh PostgreSQL database
   2. Configure Airflow 3.1.6 with FAB auth manager:
   [core]
   auth_manager = 
airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager
   3. Run database migration:
   airflow db migrate
   4. Check the column sizes:
   \d+ ab_user;
   5. Observe first_name and last_name are VARCHAR(64) instead of VARCHAR(256)
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to