Skip to content
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

Add delete_attachments to schema #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tulinmola
Copy link

Added delete_attachments to easily delete file contents when deleting schema data using changesets. Readme file has been updated with an example.

Some changes have been made to tests because of some problems with mocks. I was trying not to change them too much. But here are (commented in commit): DummyDefinition being in the same file than schema test caused mock library to fail in some cases (as it documentation says, because of the way mock overrides the module, it must be defined in a separate file from the test file). That's why definition module was declared in setup for each test, causing some warnings that are gone now.

Just tell me if you need something more. Thanks for the library!

DummyDefinition being in the same file than schema test caused
mock library to fail in some cases (as it documentation says,
because of the way mock overrides the module, it must be defined
in a separate file from the test file). That's why definition
module was declared in setup for each test, causing some warnings
that are gone now.
@danschultzer
Copy link

I could use this. @stavro wdyt?


def delete_attachments(changeset_or_data, fields) do
scope = case changeset_or_data do
%Ecto.Changeset{} -> Ecto.Changeset.apply_changes(changeset_or_data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario works for removing attachment with parent entity. But what if we will add the third case?
When field has changes we could remove attachment from S3 because field would be updated with new attachment without removing parent entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants