Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-06-02 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  minusf
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  migration extension  | Triage Stage:  Ready for
  postgresql |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"22a59c01c00cf9fbefaee0e8e67fab82bbaf1fd2" 22a59c01]:
 {{{
 #!CommitTicketReference repository=""
 revision="22a59c01c00cf9fbefaee0e8e67fab82bbaf1fd2"
 Refs #31615 -- Added EXISTS clauses to extension operations.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.fa9e4ef2c52fd509f91077e0532a0247%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-27 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  minusf
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:  migration extension  | Triage Stage:  Ready for
  postgresql |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"f3ed42c8ad3757e7238bf2f326532f5b129aa102" f3ed42c8]:
 {{{
 #!CommitTicketReference repository=""
 revision="f3ed42c8ad3757e7238bf2f326532f5b129aa102"
 Refs #31615 -- Improved creating extension docs.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.4d964e6569d0b49c2f28080d7b595c9c%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-27 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  minusf
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  migration extension  | Triage Stage:  Ready for
  postgresql |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"a79d0c8c81847e9ccde42e406bb5b411bab4214a" a79d0c8c]:
 {{{
 #!CommitTicketReference repository=""
 revision="a79d0c8c81847e9ccde42e406bb5b411bab4214a"
 [3.1.x] Refs #31615 -- Improved creating extension docs.

 Backport of f3ed42c8ad3757e7238bf2f326532f5b129aa102 from master
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e9203bdc1b1638c86c5b5a31effbbd3e%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-27 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  minusf
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  migration extension  | Triage Stage:  Ready for
  postgresql |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"d693a086def21d843c03ec3f5b5e697ed2463d45" d693a086]:
 {{{
 #!CommitTicketReference repository=""
 revision="d693a086def21d843c03ec3f5b5e697ed2463d45"
 Fixed #31615 -- Made migrations skip extension operations if not needed.

 - Don't try to create an existing extension.
 - Don't try to drop a nonexistent extension.
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.5371c347b712c7e72bdaea6d45b29c09%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-26 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  minusf
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:  migration extension  | Triage Stage:  Ready for
  postgresql |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * owner:  nobody => minusf
 * needs_better_patch:  1 => 0
 * status:  new => assigned
 * needs_tests:  1 => 0
 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.0f4ba4507a193054b5a6a87f0ea49326%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-24 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:  migration extension  | Triage Stage:  Accepted
  postgresql |
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c41199acf7d65a529200cfad1e7226c3%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-22 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:  migration extension  | Triage Stage:  Accepted
  postgresql |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by minusf):

 please have a look at this one:
 https://github.com/django/django/pull/12952

 git got the better of me :/

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.a8424e79693f619c0afc0fd87618bf31%40djangoproject.com.


Re: [Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-20 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
 Reporter:  minusf   |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Migrations   |  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:  migration extension  | Triage Stage:  Accepted
  postgresql |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Claude Paroz):

 * has_patch:  1 => 0
 * type:  Bug => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 I'm in favor. Please check again the `Has patch` box when a GitHub PR is
 available.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d08c13d94bda72c1ab0565b20097e916%40djangoproject.com.


[Django] #31615: Do not fail migration if postgresql extension is already installed and user is not superuser

2020-05-20 Thread Django
#31615: Do not fail migration if postgresql extension is already installed and 
user
is not superuser
-+-
   Reporter:  minusf |  Owner:  nobody
   Type:  Bug| Status:  new
  Component: |Version:  3.0
  Migrations |   Keywords:  migration extension
   Severity:  Normal |  postgresql
   Triage Stage: |  Has patch:  1
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  1
  UI/UX:  0  |
-+-
 Currently Django facilitates installing postgres extensions using
 migration operations:
 https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/operations/

 But having a superuser is a tall order in certain environments, and the
 manual helpfully points out:

 If the Django database user doesn’t have superuser privileges, you’ll have
 to create the extension outside of Django migrations with a user that has
 the appropriate privileges.

 This is fairly often the case with Salt and other orchestration systems.

 However having a non-superuser will break any migrations using these
 operations because unfortunately `CREATE EXTENSION` even with `IF NOT
 EXISTS` still requires superuser privileges... In other words, if the
 extension is already in place, the migration will fail...

 I think a failsafe like this around CREATE/DROP EXTENSION would make the
 migrations more robust and user friendly.

 {{{
 diff --git a/django/contrib/postgres/operations.py
 b/django/contrib/postgres/operations.py
 index 0bb131ddf2..46fc11f63f 100644
 --- a/django/contrib/postgres/operations.py
 +++ b/django/contrib/postgres/operations.py
 @@ -21,7 +21,13 @@ class CreateExtension(Operation):
  not router.allow_migrate(schema_editor.connection.alias,
 app_label)
  ):
  return
 -schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" %
 schema_editor.quote_name(self.name))
 +
 +cur = schema_editor.connection.cursor()
 +cur.execute("SELECT * FROM pg_extension WHERE extname = %s",
 [self.name])
 +if not cur.fetchone():
 +schema_editor.execute(
 +"CREATE EXTENSION IF NOT EXISTS %s" %
 schema_editor.quote_name(self.name)
 +)
  # Clear cached, stale oids.
  get_hstore_oids.cache_clear()
  get_citext_oids.cache_clear()
 @@ -33,7 +39,13 @@ class CreateExtension(Operation):
  def database_backwards(self, app_label, schema_editor, from_state,
 to_state):
  if not router.allow_migrate(schema_editor.connection.alias,
 app_label):
  return
 -schema_editor.execute("DROP EXTENSION %s" %
 schema_editor.quote_name(self.name))
 +
 +cur = schema_editor.connection.cursor()
 +cur.execute("SELECT * FROM pg_extension WHERE extname = %s",
 [self.name])
 +if cur.fetchone():
 +schema_editor.execute(
 +"DROP EXTENSION %s" % schema_editor.quote_name(self.name)
 +)
  # Clear cached, stale oids.
  get_hstore_oids.cache_clear()
  get_citext_oids.cache_clear()
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.d4a7512325c3974cbc631d30dc90716f%40djangoproject.com.