-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ali-zahedi/feat/multi-accounts
feat: support multi accounts
- Loading branch information
Showing
7 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 5.0.3 on 2024-12-03 14:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def _migrate_from_old_column(apps, schema_editor) -> None: | ||
UpdateState = apps.get_model("django_telethon", "UpdateState") | ||
i = 0 | ||
for update_state in UpdateState.objects.all(): | ||
i += 1 | ||
UpdateState.objects.filter(id=update_state.id).update(id=i, entity_id=update_state.id) | ||
|
||
# Step 2: Reset primary keys | ||
with schema_editor.connection.cursor() as cursor: | ||
cursor.execute(f"ALTER SEQUENCE {UpdateState._meta.db_table}_id_seq RESTART WITH {i + 1}") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('django_telethon', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='updatestate', | ||
name='entity_id', | ||
field=models.BigIntegerField(null=True), | ||
), | ||
migrations.RunPython( | ||
_migrate_from_old_column, | ||
reverse_code=lambda x, y: None, | ||
), | ||
] |
21 changes: 21 additions & 0 deletions
21
django_telethon/migrations/0003_alter_updatestate_entity_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 5.0.3 on 2024-12-03 17:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('django_telethon', '0002_updatestate_entity'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='updatestate', | ||
name='entity_id', | ||
field=models.BigIntegerField(db_index=True), | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='updatestate', | ||
unique_together={('client_session', 'entity_id')}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters