-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add block explorer uri templates (#176)
Add Block Explorer URI templates for address and tx_hash
- Loading branch information
Showing
5 changed files
with
67 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 3.2.5 on 2021-07-26 08:25 | ||
from django.db import migrations, models | ||
from django.db.models import F | ||
|
||
|
||
def copy_block_explorer_uri(apps, schema_editor): | ||
chain_model = apps.get_model("chains", "chain") | ||
db_alias = schema_editor.connection.alias | ||
chain_model.objects.using(db_alias).all().update( | ||
block_explorer_uri_address_template=F("block_explorer_uri"), | ||
block_explorer_uri_tx_hash_template=F("block_explorer_uri"), | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("chains", "0019_add_safe_apps_rpc"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="chain", | ||
name="block_explorer_uri_address_template", | ||
field=models.URLField(default=""), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="block_explorer_uri_tx_hash_template", | ||
field=models.URLField(default=""), | ||
preserve_default=False, | ||
), | ||
# Reverse means deleting the fields but this is accomplished via the reverse of AddField | ||
# so an empty lambda function is provided | ||
migrations.RunPython(copy_block_explorer_uri, lambda apps, schema_editor: None), | ||
] |
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
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