This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 7068341  Inrease length of the email and username (#19932)
7068341 is described below

commit 70683412bcfdaf04c4545980060db18e25cbc1c9
Author: Ɓukasz Wyszomirski <[email protected]>
AuthorDate: Sun Dec 5 23:31:35 2021 +0100

    Inrease length of the email and username (#19932)
---
 ...27fdd3_increase_length_of_email_and_username.py | 54 ++++++++++++++++++++++
 airflow/www/fab_security/sqla/models.py            |  8 ++--
 docs/apache-airflow/migrations-ref.rst             |  5 +-
 3 files changed, 62 insertions(+), 5 deletions(-)

diff --git 
a/airflow/migrations/versions/5e3ec427fdd3_increase_length_of_email_and_username.py
 
b/airflow/migrations/versions/5e3ec427fdd3_increase_length_of_email_and_username.py
new file mode 100644
index 0000000..54325bf
--- /dev/null
+++ 
b/airflow/migrations/versions/5e3ec427fdd3_increase_length_of_email_and_username.py
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Increase length of email and username
+
+Revision ID: 5e3ec427fdd3
+Revises: be2bfac3da23
+Create Date: 2021-12-01 11:49:26.390210
+
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = '5e3ec427fdd3'
+down_revision = 'be2bfac3da23'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    """Increase length of email from 64 to 256 characters"""
+    with op.batch_alter_table('ab_user') as batch_op:
+        batch_op.alter_column('username', type_=sa.String(256))
+        batch_op.alter_column('email', type_=sa.String(256))
+    with op.batch_alter_table('ab_register_user') as batch_op:
+        batch_op.alter_column('username', type_=sa.String(256))
+        batch_op.alter_column('email', type_=sa.String(256))
+
+
+def downgrade():
+    """Revert length of email from 256 to 64 characters"""
+    with op.batch_alter_table('ab_user') as batch_op:
+        batch_op.alter_column('username', type_=sa.String(64))
+        batch_op.alter_column('email', type_=sa.String(64))
+    with op.batch_alter_table('ab_register_user') as batch_op:
+        batch_op.alter_column('username', type_=sa.String(64))
+        batch_op.alter_column('email', type_=sa.String(64))
diff --git a/airflow/www/fab_security/sqla/models.py 
b/airflow/www/fab_security/sqla/models.py
index 9aa833e..685b0a8 100644
--- a/airflow/www/fab_security/sqla/models.py
+++ b/airflow/www/fab_security/sqla/models.py
@@ -125,10 +125,10 @@ class User(Model):
     id = Column(Integer, Sequence("ab_user_id_seq"), primary_key=True)
     first_name = Column(String(64), nullable=False)
     last_name = Column(String(64), nullable=False)
-    username = Column(String(64), unique=True, nullable=False)
+    username = Column(String(256), unique=True, nullable=False)
     password = Column(String(256))
     active = Column(Boolean)
-    email = Column(String(64), unique=True, nullable=False)
+    email = Column(String(256), unique=True, nullable=False)
     last_login = Column(DateTime)
     login_count = Column(Integer)
     fail_login_count = Column(Integer)
@@ -195,8 +195,8 @@ class RegisterUser(Model):
     id = Column(Integer, Sequence("ab_register_user_id_seq"), primary_key=True)
     first_name = Column(String(64), nullable=False)
     last_name = Column(String(64), nullable=False)
-    username = Column(String(64), unique=True, nullable=False)
+    username = Column(String(256), unique=True, nullable=False)
     password = Column(String(256))
-    email = Column(String(64), nullable=False)
+    email = Column(String(256), nullable=False)
     registration_date = Column(DateTime, default=datetime.datetime.now, 
nullable=True)
     registration_hash = Column(String(256))
diff --git a/docs/apache-airflow/migrations-ref.rst 
b/docs/apache-airflow/migrations-ref.rst
index 016c624..d0cb10e 100644
--- a/docs/apache-airflow/migrations-ref.rst
+++ b/docs/apache-airflow/migrations-ref.rst
@@ -23,7 +23,10 @@ Here's the list of all the Database Migrations that are 
executed via when you ru
 
+--------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------+
 | Revision ID                    | Revises ID       | Airflow Version | 
Description                                                                     
      |
 
+--------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------+
-| ``be2bfac3da23`` (head)        | ``7b2661a43ba3`` | ``2.2.3``       | Add 
has_import_errors column to DagModel                                            
  |
+| ``5e3ec427fdd3`` (head)        | ``be2bfac3da23`` | ``2.2.3``       | 
Increase length of email and username in ``ab_user`` and ``ab_register_user`` 
table   |
+|                                |                  |                 | to 
``256`` characters                                                              
   |
++--------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------+
+| ``be2bfac3da23``               | ``7b2661a43ba3`` | ``2.2.3``       | Add 
has_import_errors column to DagModel                                            
  |
 
+--------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------+
 | ``7b2661a43ba3``               | ``142555e44c17`` | ``2.2.0``       | Change 
``TaskInstance`` and ``TaskReschedule`` tables from execution_date to run_id.  |
 
+--------------------------------+------------------+-----------------+---------------------------------------------------------------------------------------+

Reply via email to