From 9080d1c7d2443b57a19035775a67b6defec19292 Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Tue, 18 Oct 2022 16:10:33 +0100 Subject: [PATCH 1/4] Try Squashed Migrations --- .gitignore | 16 ++ .../0001_squashed_0005_auto_20211231_1702.py | 161 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py diff --git a/.gitignore b/.gitignore index e47cb7c..924096c 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,19 @@ example/ # Pycharm .idea/ +users/__init__.py +users/admin.py +users/apps.py +users/models.py +users/tests.py +users/views.py +users/migrations/__init__.py +users/migrations/0001_initial.py +users/migrations/0002_myprofile_x.py +.gitignore +project/__init__.py +project/asgi.py +project/settings.py +project/urls.py +project/wsgi.py +manage.py diff --git a/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py b/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py new file mode 100644 index 0000000..0319834 --- /dev/null +++ b/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py @@ -0,0 +1,161 @@ +# Generated by Django 4.1.2 on 2022-10-18 15:07 + +from django.db import migrations, models +import django_keycloak.managers + + +class Migration(migrations.Migration): + + replaces = [ + ("django_keycloak", "0001_initial"), + ("django_keycloak", "0002_auto_20210209_1503"), + ("django_keycloak", "0003_auto_20210406_1426"), + ("django_keycloak", "0004_keycloakuserautoid"), + ("django_keycloak", "0005_auto_20211231_1702"), + ] + + initial = True + + dependencies = [ + ("auth", "0011_update_proxy_permissions"), + ] + + operations = [ + migrations.CreateModel( + name="KeycloakUser", + fields=[ + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "username", + models.CharField( + max_length=20, unique=True, verbose_name="username" + ), + ), + ( + "id", + models.UUIDField( + primary_key=True, + serialize=False, + unique=True, + verbose_name="keycloak_id", + ), + ), + ("is_staff", models.BooleanField(default=False)), + ("is_superuser", models.BooleanField(default=False)), + ("is_active", models.BooleanField(default=True)), + ("date_joined", models.DateTimeField(auto_now_add=True)), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.permission", + verbose_name="user permissions", + ), + ), + ], + options={ + "abstract": False, + "swappable": "AUTH_USER_MODEL", + "verbose_name": "User", + "verbose_name_plural": "Users", + }, + managers=[ + ("objects", django_keycloak.managers.KeycloakUserManager()), + ], + ), + migrations.CreateModel( + name="KeycloakUserAutoId", + fields=[ + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "username", + models.CharField( + max_length=20, unique=True, verbose_name="username" + ), + ), + ("is_staff", models.BooleanField(default=False)), + ("is_superuser", models.BooleanField(default=False)), + ("is_active", models.BooleanField(default=True)), + ("date_joined", models.DateTimeField(auto_now_add=True)), + ("id", models.AutoField(primary_key=True, serialize=False)), + ( + "keycloak_id", + models.UUIDField(unique=True, verbose_name="keycloak_id"), + ), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.permission", + verbose_name="user permissions", + ), + ), + ( + "email", + models.EmailField( + blank=True, max_length=254, verbose_name="email address" + ), + ), + ( + "first_name", + models.CharField( + blank=True, max_length=150, verbose_name="first name" + ), + ), + ( + "last_name", + models.CharField( + blank=True, max_length=150, verbose_name="last name" + ), + ), + ], + options={ + "verbose_name": "User", + "verbose_name_plural": "Users", + "swappable": "AUTH_USER_MODEL", + }, + managers=[ + ("objects", django_keycloak.managers.KeycloakUserManagerAutoId()), + ], + ), + ] From b274b67bef1996bc1669aaed66e7bf54650610b8 Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Tue, 18 Oct 2022 17:15:19 +0100 Subject: [PATCH 2/4] Undo gitignore changes --- .gitignore | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.gitignore b/.gitignore index 924096c..e47cb7c 100644 --- a/.gitignore +++ b/.gitignore @@ -118,19 +118,3 @@ example/ # Pycharm .idea/ -users/__init__.py -users/admin.py -users/apps.py -users/models.py -users/tests.py -users/views.py -users/migrations/__init__.py -users/migrations/0001_initial.py -users/migrations/0002_myprofile_x.py -.gitignore -project/__init__.py -project/asgi.py -project/settings.py -project/urls.py -project/wsgi.py -manage.py From 4cb0f61140a5bb01822901e02dd304174dc9b70a Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Wed, 19 Oct 2022 12:17:51 +0100 Subject: [PATCH 3/4] Rename migration to more readable version --- .../0001_redo_migrations_0001to0005.py | 69 ++++++++ .../0001_squashed_0005_auto_20211231_1702.py | 161 ------------------ 2 files changed, 69 insertions(+), 161 deletions(-) create mode 100644 django_keycloak/migrations/0001_redo_migrations_0001to0005.py delete mode 100644 django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py diff --git a/django_keycloak/migrations/0001_redo_migrations_0001to0005.py b/django_keycloak/migrations/0001_redo_migrations_0001to0005.py new file mode 100644 index 0000000..686a62b --- /dev/null +++ b/django_keycloak/migrations/0001_redo_migrations_0001to0005.py @@ -0,0 +1,69 @@ +# Generated by Django 3.2.9 on 2022-10-19 11:16 + +from django.db import migrations, models +import django_keycloak.managers + + +class Migration(migrations.Migration): + + replaces = [('django_keycloak', '0001_initial'), ('django_keycloak', '0002_auto_20210209_1503'), ('django_keycloak', '0003_auto_20210406_1426'), ('django_keycloak', '0004_keycloakuserautoid'), ('django_keycloak', '0005_auto_20211231_1702')] + + initial = True + + dependencies = [ + ('auth', '0011_update_proxy_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='KeycloakUser', + fields=[ + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('username', models.CharField(max_length=20, unique=True, verbose_name='username')), + ('id', models.UUIDField(primary_key=True, serialize=False, unique=True, verbose_name='keycloak_id')), + ('is_staff', models.BooleanField(default=False)), + ('is_superuser', models.BooleanField(default=False)), + ('is_active', models.BooleanField(default=True)), + ('date_joined', models.DateTimeField(auto_now_add=True)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'abstract': False, + 'swappable': 'AUTH_USER_MODEL', + 'verbose_name': 'User', + 'verbose_name_plural': 'Users', + }, + managers=[ + ('objects', django_keycloak.managers.KeycloakUserManager()), + ], + ), + migrations.CreateModel( + name='KeycloakUserAutoId', + fields=[ + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('username', models.CharField(max_length=20, unique=True, verbose_name='username')), + ('is_staff', models.BooleanField(default=False)), + ('is_superuser', models.BooleanField(default=False)), + ('is_active', models.BooleanField(default=True)), + ('date_joined', models.DateTimeField(auto_now_add=True)), + ('id', models.AutoField(primary_key=True, serialize=False)), + ('keycloak_id', models.UUIDField(unique=True, verbose_name='keycloak_id')), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ], + options={ + 'verbose_name': 'User', + 'verbose_name_plural': 'Users', + 'swappable': 'AUTH_USER_MODEL', + }, + managers=[ + ('objects', django_keycloak.managers.KeycloakUserManagerAutoId()), + ], + ), + ] diff --git a/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py b/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py deleted file mode 100644 index 0319834..0000000 --- a/django_keycloak/migrations/0001_squashed_0005_auto_20211231_1702.py +++ /dev/null @@ -1,161 +0,0 @@ -# Generated by Django 4.1.2 on 2022-10-18 15:07 - -from django.db import migrations, models -import django_keycloak.managers - - -class Migration(migrations.Migration): - - replaces = [ - ("django_keycloak", "0001_initial"), - ("django_keycloak", "0002_auto_20210209_1503"), - ("django_keycloak", "0003_auto_20210406_1426"), - ("django_keycloak", "0004_keycloakuserautoid"), - ("django_keycloak", "0005_auto_20211231_1702"), - ] - - initial = True - - dependencies = [ - ("auth", "0011_update_proxy_permissions"), - ] - - operations = [ - migrations.CreateModel( - name="KeycloakUser", - fields=[ - ("password", models.CharField(max_length=128, verbose_name="password")), - ( - "last_login", - models.DateTimeField( - blank=True, null=True, verbose_name="last login" - ), - ), - ( - "username", - models.CharField( - max_length=20, unique=True, verbose_name="username" - ), - ), - ( - "id", - models.UUIDField( - primary_key=True, - serialize=False, - unique=True, - verbose_name="keycloak_id", - ), - ), - ("is_staff", models.BooleanField(default=False)), - ("is_superuser", models.BooleanField(default=False)), - ("is_active", models.BooleanField(default=True)), - ("date_joined", models.DateTimeField(auto_now_add=True)), - ( - "groups", - models.ManyToManyField( - blank=True, - help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", - related_name="user_set", - related_query_name="user", - to="auth.group", - verbose_name="groups", - ), - ), - ( - "user_permissions", - models.ManyToManyField( - blank=True, - help_text="Specific permissions for this user.", - related_name="user_set", - related_query_name="user", - to="auth.permission", - verbose_name="user permissions", - ), - ), - ], - options={ - "abstract": False, - "swappable": "AUTH_USER_MODEL", - "verbose_name": "User", - "verbose_name_plural": "Users", - }, - managers=[ - ("objects", django_keycloak.managers.KeycloakUserManager()), - ], - ), - migrations.CreateModel( - name="KeycloakUserAutoId", - fields=[ - ("password", models.CharField(max_length=128, verbose_name="password")), - ( - "last_login", - models.DateTimeField( - blank=True, null=True, verbose_name="last login" - ), - ), - ( - "username", - models.CharField( - max_length=20, unique=True, verbose_name="username" - ), - ), - ("is_staff", models.BooleanField(default=False)), - ("is_superuser", models.BooleanField(default=False)), - ("is_active", models.BooleanField(default=True)), - ("date_joined", models.DateTimeField(auto_now_add=True)), - ("id", models.AutoField(primary_key=True, serialize=False)), - ( - "keycloak_id", - models.UUIDField(unique=True, verbose_name="keycloak_id"), - ), - ( - "groups", - models.ManyToManyField( - blank=True, - help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", - related_name="user_set", - related_query_name="user", - to="auth.group", - verbose_name="groups", - ), - ), - ( - "user_permissions", - models.ManyToManyField( - blank=True, - help_text="Specific permissions for this user.", - related_name="user_set", - related_query_name="user", - to="auth.permission", - verbose_name="user permissions", - ), - ), - ( - "email", - models.EmailField( - blank=True, max_length=254, verbose_name="email address" - ), - ), - ( - "first_name", - models.CharField( - blank=True, max_length=150, verbose_name="first name" - ), - ), - ( - "last_name", - models.CharField( - blank=True, max_length=150, verbose_name="last name" - ), - ), - ], - options={ - "verbose_name": "User", - "verbose_name_plural": "Users", - "swappable": "AUTH_USER_MODEL", - }, - managers=[ - ("objects", django_keycloak.managers.KeycloakUserManagerAutoId()), - ], - ), - ] From 8968718da9880ae5409e7b199276ec3087cb72c0 Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Wed, 19 Oct 2022 12:28:43 +0100 Subject: [PATCH 4/4] run black formatter --- .../0001_redo_migrations_0001to0005.py | 166 ++++++++++++++---- 1 file changed, 129 insertions(+), 37 deletions(-) diff --git a/django_keycloak/migrations/0001_redo_migrations_0001to0005.py b/django_keycloak/migrations/0001_redo_migrations_0001to0005.py index 686a62b..de05f0f 100644 --- a/django_keycloak/migrations/0001_redo_migrations_0001to0005.py +++ b/django_keycloak/migrations/0001_redo_migrations_0001to0005.py @@ -6,64 +6,156 @@ class Migration(migrations.Migration): - replaces = [('django_keycloak', '0001_initial'), ('django_keycloak', '0002_auto_20210209_1503'), ('django_keycloak', '0003_auto_20210406_1426'), ('django_keycloak', '0004_keycloakuserautoid'), ('django_keycloak', '0005_auto_20211231_1702')] + replaces = [ + ("django_keycloak", "0001_initial"), + ("django_keycloak", "0002_auto_20210209_1503"), + ("django_keycloak", "0003_auto_20210406_1426"), + ("django_keycloak", "0004_keycloakuserautoid"), + ("django_keycloak", "0005_auto_20211231_1702"), + ] initial = True dependencies = [ - ('auth', '0011_update_proxy_permissions'), + ("auth", "0011_update_proxy_permissions"), ] operations = [ migrations.CreateModel( - name='KeycloakUser', + name="KeycloakUser", fields=[ - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('username', models.CharField(max_length=20, unique=True, verbose_name='username')), - ('id', models.UUIDField(primary_key=True, serialize=False, unique=True, verbose_name='keycloak_id')), - ('is_staff', models.BooleanField(default=False)), - ('is_superuser', models.BooleanField(default=False)), - ('is_active', models.BooleanField(default=True)), - ('date_joined', models.DateTimeField(auto_now_add=True)), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "username", + models.CharField( + max_length=20, unique=True, verbose_name="username" + ), + ), + ( + "id", + models.UUIDField( + primary_key=True, + serialize=False, + unique=True, + verbose_name="keycloak_id", + ), + ), + ("is_staff", models.BooleanField(default=False)), + ("is_superuser", models.BooleanField(default=False)), + ("is_active", models.BooleanField(default=True)), + ("date_joined", models.DateTimeField(auto_now_add=True)), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.Group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.Permission", + verbose_name="user permissions", + ), + ), ], options={ - 'abstract': False, - 'swappable': 'AUTH_USER_MODEL', - 'verbose_name': 'User', - 'verbose_name_plural': 'Users', + "abstract": False, + "swappable": "AUTH_USER_MODEL", + "verbose_name": "User", + "verbose_name_plural": "Users", }, managers=[ - ('objects', django_keycloak.managers.KeycloakUserManager()), + ("objects", django_keycloak.managers.KeycloakUserManager()), ], ), migrations.CreateModel( - name='KeycloakUserAutoId', + name="KeycloakUserAutoId", fields=[ - ('password', models.CharField(max_length=128, verbose_name='password')), - ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), - ('username', models.CharField(max_length=20, unique=True, verbose_name='username')), - ('is_staff', models.BooleanField(default=False)), - ('is_superuser', models.BooleanField(default=False)), - ('is_active', models.BooleanField(default=True)), - ('date_joined', models.DateTimeField(auto_now_add=True)), - ('id', models.AutoField(primary_key=True, serialize=False)), - ('keycloak_id', models.UUIDField(unique=True, verbose_name='keycloak_id')), - ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), - ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), - ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), - ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ("password", models.CharField(max_length=128, verbose_name="password")), + ( + "last_login", + models.DateTimeField( + blank=True, null=True, verbose_name="last login" + ), + ), + ( + "username", + models.CharField( + max_length=20, unique=True, verbose_name="username" + ), + ), + ("is_staff", models.BooleanField(default=False)), + ("is_superuser", models.BooleanField(default=False)), + ("is_active", models.BooleanField(default=True)), + ("date_joined", models.DateTimeField(auto_now_add=True)), + ("id", models.AutoField(primary_key=True, serialize=False)), + ( + "keycloak_id", + models.UUIDField(unique=True, verbose_name="keycloak_id"), + ), + ( + "groups", + models.ManyToManyField( + blank=True, + help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", + related_name="user_set", + related_query_name="user", + to="auth.Group", + verbose_name="groups", + ), + ), + ( + "user_permissions", + models.ManyToManyField( + blank=True, + help_text="Specific permissions for this user.", + related_name="user_set", + related_query_name="user", + to="auth.Permission", + verbose_name="user permissions", + ), + ), + ( + "email", + models.EmailField( + blank=True, max_length=254, verbose_name="email address" + ), + ), + ( + "first_name", + models.CharField( + blank=True, max_length=150, verbose_name="first name" + ), + ), + ( + "last_name", + models.CharField( + blank=True, max_length=150, verbose_name="last name" + ), + ), ], options={ - 'verbose_name': 'User', - 'verbose_name_plural': 'Users', - 'swappable': 'AUTH_USER_MODEL', + "verbose_name": "User", + "verbose_name_plural": "Users", + "swappable": "AUTH_USER_MODEL", }, managers=[ - ('objects', django_keycloak.managers.KeycloakUserManagerAutoId()), + ("objects", django_keycloak.managers.KeycloakUserManagerAutoId()), ], ), ]