-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: initial work to separate task processor from main repository #1
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0eef3fb
Initial work to separate task processor from main repository
matthewelwell 8932e74
Fix workflow
matthewelwell e36e79c
Add pointless __init__ file
matthewelwell aa6f02e
Remove pointless __init__ file
matthewelwell e1546ea
Loosen Django dependency
matthewelwell 89082cd
Update readme wording and example
matthewelwell 538413a
typing.Optional -> `|`
matthewelwell 58610fa
Add comment to seemingly unused import.
matthewelwell 9b8f17e
Add TODO
matthewelwell 7d469ae
Remove unnecessary typing import
matthewelwell 93b141e
Add typing to managers module
matthewelwell fc82670
Formatting
matthewelwell 52fb316
Refactor helpers
matthewelwell b422789
Add __init__.py
matthewelwell 1016207
Explicitly include sql files
matthewelwell 5de1083
More pyproject changes
matthewelwell 1fd3176
re-add __init__ and change pyproject include
matthewelwell 20e2723
change include definition
matthewelwell 1152d0b
Add build-system
matthewelwell cf373be
Add return types to manager methods
matthewelwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,29 +1,9 @@ | ||
import os | ||
import typing | ||
from contextlib import suppress | ||
""" | ||
Note: django doesn't support adding submodules to the migrations module directory | ||
that don't include a Migration class. As such, I've defined this helpers submodule | ||
and simplified the imports by defining the __all__ attribute. | ||
""" | ||
|
||
from django.db import migrations | ||
from task_processor.migrations.helpers.postgres_helpers import PostgresOnlyRunSQL | ||
|
||
|
||
class PostgresOnlyRunSQL(migrations.RunSQL): | ||
@classmethod | ||
def from_sql_file( | ||
cls, | ||
file_path: typing.Union[str, os.PathLike], | ||
reverse_sql: typing.Union[str, os.PathLike] = None, | ||
) -> "PostgresOnlyRunSQL": | ||
with open(file_path) as forward_sql: | ||
with suppress(FileNotFoundError, TypeError): | ||
with open(reverse_sql) as reverse_sql_file: | ||
reverse_sql = reverse_sql_file.read() | ||
return cls(forward_sql.read(), reverse_sql=reverse_sql) | ||
|
||
def database_forwards(self, app_label, schema_editor, from_state, to_state): | ||
if schema_editor.connection.vendor != "postgresql": | ||
return | ||
super().database_forwards(app_label, schema_editor, from_state, to_state) | ||
|
||
def database_backwards(self, app_label, schema_editor, from_state, to_state): | ||
if schema_editor.connection.vendor != "postgresql": | ||
return | ||
super().database_backwards(app_label, schema_editor, from_state, to_state) | ||
__all__ = ["PostgresOnlyRunSQL"] |
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,29 @@ | ||
import os | ||
import typing | ||
from contextlib import suppress | ||
|
||
from django.db import migrations | ||
|
||
|
||
class PostgresOnlyRunSQL(migrations.RunSQL): | ||
@classmethod | ||
def from_sql_file( | ||
cls, | ||
file_path: typing.Union[str, os.PathLike], | ||
reverse_sql: typing.Union[str, os.PathLike] = None, | ||
) -> "PostgresOnlyRunSQL": | ||
with open(file_path) as forward_sql: | ||
with suppress(FileNotFoundError, TypeError): | ||
with open(reverse_sql) as reverse_sql_file: | ||
reverse_sql = reverse_sql_file.read() | ||
return cls(forward_sql.read(), reverse_sql=reverse_sql) | ||
|
||
def database_forwards(self, app_label, schema_editor, from_state, to_state): | ||
if schema_editor.connection.vendor != "postgresql": | ||
return | ||
super().database_forwards(app_label, schema_editor, from_state, to_state) | ||
|
||
def database_backwards(self, app_label, schema_editor, from_state, to_state): | ||
if schema_editor.connection.vendor != "postgresql": | ||
return | ||
super().database_backwards(app_label, schema_editor, from_state, to_state) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change 👍🏼