-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-warehouse): migrations for data sync (#18966)
* just code for migrations * use all timezones because update would cause common_timezones to be less inclusive * install new dependencies * add comment * revert * restore * fix type
- Loading branch information
Showing
16 changed files
with
246 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Generated by Django 3.2.19 on 2023-11-22 19:39 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import encrypted_fields.fields | ||
import posthog.models.utils | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("posthog", "0366_alter_action_created_by"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="externaldatasource", | ||
name="job_inputs", | ||
field=encrypted_fields.fields.EncryptedJSONField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="datawarehousetable", | ||
name="external_data_source", | ||
field=models.ForeignKey( | ||
blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to="posthog.externaldatasource" | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="ExternalDataJob", | ||
fields=[ | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False | ||
), | ||
), | ||
("status", models.CharField(max_length=400)), | ||
("rows_synced", models.BigIntegerField(blank=True, null=True)), | ||
( | ||
"latest_error", | ||
models.TextField(help_text="The latest error that occurred during this run.", null=True), | ||
), | ||
( | ||
"created_by", | ||
models.ForeignKey( | ||
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
( | ||
"pipeline", | ||
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.externaldatasource"), | ||
), | ||
("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.AlterField( | ||
model_name="team", | ||
name="timezone", | ||
field=models.CharField(choices=posthog.models.team.TIMEZONES, default="UTC", max_length=240), | ||
), | ||
] |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .table import * | ||
from .credential import * | ||
from .datawarehouse_saved_query import * | ||
from .view_link import * | ||
from .external_data_job import * | ||
from .external_data_source import * | ||
from .table import * | ||
from .view_link import * |
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,22 @@ | ||
from django.db import models | ||
|
||
from posthog.models.team import Team | ||
from posthog.models.utils import CreatedMetaFields, UUIDModel, sane_repr | ||
|
||
|
||
class ExternalDataJob(CreatedMetaFields, UUIDModel): | ||
class Status(models.TextChoices): | ||
RUNNING = "Running", "Running" | ||
FAILED = "Failed", "Failed" | ||
COMPLETED = "Completed", "Completed" | ||
CANCELLED = "Cancelled", "Cancelled" | ||
|
||
team: models.ForeignKey = models.ForeignKey(Team, on_delete=models.CASCADE) | ||
pipeline: models.ForeignKey = models.ForeignKey("posthog.ExternalDataSource", on_delete=models.CASCADE) | ||
status: models.CharField = models.CharField(max_length=400) | ||
rows_synced: models.BigIntegerField = models.BigIntegerField(null=True, blank=True) | ||
latest_error: models.TextField = models.TextField( | ||
null=True, help_text="The latest error that occurred during this run." | ||
) | ||
|
||
__repr__ = sane_repr("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
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
Oops, something went wrong.