Skip to content

Remove django-guardian db #5875

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

Closed
stsewd opened this issue Jul 2, 2019 · 7 comments
Closed

Remove django-guardian db #5875

stsewd opened this issue Jul 2, 2019 · 7 comments
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required

Comments

@stsewd
Copy link
Member

stsewd commented Jul 2, 2019

Django guardian was removed #5863, but we still have the tables on the db. Probably we want to do this after the deploy and when we are sure that nothing is broken.

https://django-guardian.readthedocs.io/en/stable/api/guardian.models.html#std:model-UserObjectPermission

@stsewd stsewd added the Improvement Minor improvement to code label Jul 2, 2019
@tapaswenipathak
Copy link
Contributor

Hello @stsewd, Can I do take this?

@stsewd
Copy link
Member Author

stsewd commented Jul 15, 2019

Sure! You should run the migrations after #5863 was merged to see what can be removed (or take a look at https://github.com/django-guardian/django-guardian/tree/devel/guardian/migrations), and make a migration removing those models.

@stsewd
Copy link
Member Author

stsewd commented Aug 8, 2019

So, we have two ways to remove the migration. We actually needed to execute the first one before the deploy :/

The first one removes all the migrations from the db, and the second one is the sql to execute directly on the db (in case we can't do 1).

All this commands should be run from the commit c907f03 (just before the one that removes the app)

$ dj migrate --fake guardian zero
Operations to perform:
  Unapply all migrations: guardian
Running migrations:
  Rendering model states... DONE
  Unapplying guardian.0001_initial... FAKED
~/rtd/readthedocs.org on  c907f03a9! ⌚ 1:07:32
$ dj sqlmigrate --backwards guardian 0001_initial
BEGIN;
--
-- Alter unique_together for groupobjectpermission (1 constraint(s))
--
ALTER TABLE "guardian_groupobjectpermission" DROP CONSTRAINT "guardian_groupobjectperm_group_id_permission_id_o_3f189f7c_uniq";
--
-- Alter unique_together for userobjectpermission (1 constraint(s))
--
ALTER TABLE "guardian_userobjectpermission" DROP CONSTRAINT "guardian_userobjectpermi_user_id_permission_id_ob_b0b3d2fc_uniq";
--
-- Create model UserObjectPermission
--
DROP TABLE "guardian_userobjectpermission" CASCADE;
--
-- Create model GroupObjectPermission
--
DROP TABLE "guardian_groupobjectpermission" CASCADE;
COMMIT;

@tapaswenipathak
Copy link
Contributor

tapaswenipathak commented Aug 8, 2019

@stsewd Do you wanna let me finish the issue or you wanna take that on your head?

@stsewd
Copy link
Member Author

stsewd commented Aug 8, 2019

@tapaswenipathak this now needs a design decision. We need to execute the SQL or the command in the production server.

@stsewd stsewd added the Needed: design decision A core team decision is required label Aug 8, 2019
@ericholscher
Copy link
Member

Ran into an issue running the backwards migration in prod. Going to have to hand-run the SQL.

@stsewd
Copy link
Member Author

stsewd commented Aug 13, 2019

This was fixed, we executed the drop sql in the db

@stsewd stsewd closed this as completed Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code Needed: design decision A core team decision is required
Projects
None yet
Development

No branches or pull requests

3 participants