Re: [Django] #23749: migrations.RunPython broken with dbrouters.

2014-11-04 Thread Django
#23749: migrations.RunPython broken with dbrouters.
-+-
 Reporter:  alfredperlstein  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:  migrations dbrouter  | Triage Stage:
Has patch:  0|  Unreviewed
  Needs tests:  0|  Needs documentation:  0
Easy pickings:  0|  Patch needs improvement:  0
 |UI/UX:  0
-+-

Comment (by timgraham):

 Ah yes, that was the ticket I was looking for but couldn't find - forgot
 it had been closed. Anyway, wouldn't `schema_editor.connection.alias` give
 you the name of the database? If so, we should likely document the
 solution.

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.df27eb2623e9d7a4a3dcf4eede68a60d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23749: migrations.RunPython broken with dbrouters.

2014-11-03 Thread Django
#23749: migrations.RunPython broken with dbrouters.
-+-
 Reporter:  alfredperlstein  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:  migrations dbrouter  | Triage Stage:
Has patch:  0|  Unreviewed
  Needs tests:  0|  Needs documentation:  0
Easy pickings:  0|  Patch needs improvement:  0
 |UI/UX:  0
-+-

Comment (by splbio):

 To be honest this is more like #22583.

 #23273 is too complex for me to parse, there may be some overlap, but I do
 not think so.

 All that is needed is that we somehow pass the --database=FOO option to
 the RunPython method as a kwarg so that the router can provide a function
 to query that... OR that the migration itself can decide.

 I am not sure why the name of the db is not given to the RunPython method.

 This is a relatively simple request, can this please be fixed?

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.26184a06e7631eab75bfd342f9299c49%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23749: migrations.RunPython broken with dbrouters.

2014-11-03 Thread Django
#23749: migrations.RunPython broken with dbrouters.
-+-
 Reporter:  alfredperlstein  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:  migrations dbrouter  | Triage Stage:
Has patch:  0|  Unreviewed
  Needs tests:  0|  Needs documentation:  0
Easy pickings:  0|  Patch needs improvement:  0
 |UI/UX:  0
-+-

Comment (by timgraham):

 I think this is a duplicate of #23273 (or at least closely related to).
 Have you read that ticket?

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.8c44abc8321795038711db3127912925%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #23749: migrations.RunPython broken with dbrouters.

2014-11-02 Thread Django
#23749: migrations.RunPython broken with dbrouters.
-+-
 Reporter:  alfredperlstein  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  1.7
 Severity:  Normal   |   Resolution:
 Keywords:  migrations dbrouter  | Triage Stage:
Has patch:  0|  Unreviewed
  Needs tests:  0|  Needs documentation:  0
Easy pickings:  0|  Patch needs improvement:  0
 |UI/UX:  0
-+-
Changes (by alfredperlstein):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Traceback I get is as follows:
 {{{
 + psql -U pgsql -d postgres -c 'create database historicallogs'
 CREATE DATABASE
 + python manage.py migrate mycompany --noinput --traceback --database=logs
 Operations to perform:
   Apply all migrations: mycompany
 Running migrations:
   Applying mycompany.0001_initial... OK
   Applying mycompany.0002_auto_20140904_1549... OK
   Applying mycompany.0003_auto_20141006_1134... OK
   Applying mycompany.0004_blockd_bkd_ports... OK
   Applying mycompany.0005_auto_direction_and_indexes... OK
   Applying mycompany.0006_auto_20141103_1539...Traceback (most recent call
 last):
   File "manage.py", line 42, in 
 execute_from_command_line(sys.argv)
   File "/usr/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 385, in
 execute_from_command_line
 utility.execute()
   File "/usr/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 377, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/usr/local/lib/python2.7/site-
 packages/django/core/management/base.py", line 288, in run_from_argv
 self.execute(*args, **options.__dict__)
   File "/usr/local/lib/python2.7/site-
 packages/django/core/management/base.py", line 338, in execute
 output = self.handle(*args, **options)
   File "/usr/local/lib/python2.7/site-
 packages/django/core/management/commands/migrate.py", line 160, in handle
 executor.migrate(targets, plan, fake=options.get("fake", False))
   File "/usr/local/lib/python2.7/site-
 packages/django/db/migrations/executor.py", line 63, in migrate
 self.apply_migration(migration, fake=fake)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/migrations/executor.py", line 97, in apply_migration
 migration.apply(project_state, schema_editor)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/migrations/migration.py", line 107, in apply
 operation.database_forwards(self.app_label, schema_editor,
 project_state, new_state)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/migrations/operations/special.py", line 117, in
 database_forwards
 self.code(from_state.render(), schema_editor)
   File
 
"/usr/local/www/applianceUI/applianceUI/mycompany/migrations/0006_auto_20141103_1539.py",
 line 8, in bkd_default_ports
 bkd = Blockd.objects.config()
   File
 "/usr/local/www/applianceUI/applianceUI/freeadmin/models/__init__.py",
 line 59, in config
 obj = self.order_by("-id")[0]
   File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py",
 line 177, in __getitem__
 return list(qs)[0]
   File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py",
 line 141, in __iter__
 self._fetch_all()
   File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py",
 line 966, in _fetch_all
 self._result_cache = list(self.iterator())
   File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py",
 line 265, in iterator
 for row in compiler.results_iter():
   File "/usr/local/lib/python2.7/site-
 packages/django/db/models/sql/compiler.py", line 700, in results_iter
 for rows in self.execute_sql(MULTI):
   File "/usr/local/lib/python2.7/site-
 packages/django/db/models/sql/compiler.py", line 786, in execute_sql
 cursor.execute(sql, params)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 65, in execute
 return self.cursor.execute(sql, params)
   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line
 94, in __exit__
 six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/backends/utils.py", line 65, in execute
 return self.cursor.execute(sql, params)
   File "/usr/local/lib/python2.7/site-
 packages/django/db/backends/sqlite3/base.py", line 485, in execute
 return Database.Cursor.execute(self, query, params)
 django.db.utils.OperationalError: no such table: mycompany_blockd
 + su - pgsql -c '/usr/local/bin/pg_ctl stop -w -D /data/pgsql/data'
 waiting for server to

[Django] #23749: migrations.RunPython broken with dbrouters.

2014-11-02 Thread Django
#23749: migrations.RunPython broken with dbrouters.
-+-
 Reporter:  alfredperlstein  |  Owner:  nobody
 Type:  Bug  | Status:  new
Component:  Migrations   |Version:  1.7
 Severity:  Normal   |   Keywords:  migrations dbrouter
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0|  UI/UX:  0
-+-
 It seems that the migration system in 1.7 does not properly query the
 dbrouter setup when a migrations.RunPython method is invoked.

 Running the following command:
 {{{
 python manage.py migrate mycompany --noinput --traceback --database=logs
 --verbosity=2
 }}}

 Never seems to call the router for the following migration, so as you can
 see I've added code to parse sys.argv as an experiment which seems to
 sort-of work, but really looks like the wrong way to do this.

 {{{
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals

 from django.db import models, migrations
 from applianceUI.mycompany.dbrouter import LogRouter
 import sys

 def bkd_default_ports(apps, schema_editor):
 db = None
 for arg in sys.argv:
 if '=' not in arg:
 continue
 print "arg: ",  arg
 k, v = arg.split('=', 2)
 print "k: '%s', v: '%s'  " % (k,v)

 if k == "--database":
 print arg
 db = v
 break

 print "db is %s" % db
 router = LogRouter()
 Blockd = apps.get_model("mycompany", "Blockd")

 if router.allow_migrate(db, Blockd) is False:
 return

 try:
 bkd = Blockd.objects.order_by("-id")[0]
 except IndexError:
 bkd = Blockd.objects.create()
 if bkd.bkd_ports is "":
 bkd.bkd_ports = "80, 8080, 3128"
 bkd.save()


 class Migration(migrations.Migration):

 dependencies = [
 ('mycompany', '0005_auto_direction_and_indexes'),
 ]

 operations = [
 migrations.RunPython(bkd_default_ports),
 ]
 }}}

 The arguments apps and schema_editor didn't give me enough data to make my
 decision.  How can i properly derive that the database is "logs"?

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.fcdc5c4eb6da32d67646d622d2a27c2b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.