You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have two databases, an operational and a history database. I've setup my db router such that all the historical tables get migrated onto the history database. However, commands that create operational models (users for instance) do not forward historical records to the history database. Instead, they attempt to lookup the history table in the operational database. This causes an error:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'operational-db.operational-db_historicaluser' doesn't exist")
So far, I've initialized the HistoricalRecord instance like this:
history = HistoricalRecords(history_user_id_field=models.IntegerField(null=True), history_user_getter=_history_user_getter)
where my _history_user_getter is a function that accepts a historical_instance.
I assume there must be a way to configure the historical model to use a separate database. How do I do that?
To Reproduce
Steps to reproduce the behavior:
Configure your dbrouter.py file to run a historicaluser migration on a separate database
Run the migrations & verify the table has been created
Attempt to create a superuser (python manage.py createsuperuser)
Observe the error that appears
Expected behavior
I'd like to see a record in the historicaluser table (in the history database) that describes a user created in the operational database.
Environment (please complete the following information):
OS: Mac OSX Mojave
Django Simple History Version: 2.7.0
Django Version: 2.1
Database Version: MySQL
The text was updated successfully, but these errors were encountered:
Describe the bug
I have two databases, an operational and a history database. I've setup my db router such that all the historical tables get migrated onto the history database. However, commands that create operational models (users for instance) do not forward historical records to the history database. Instead, they attempt to lookup the history table in the operational database. This causes an error:
So far, I've initialized the
HistoricalRecord
instance like this:where my
_history_user_getter
is a function that accepts ahistorical_instance
.I assume there must be a way to configure the historical model to use a separate database. How do I do that?
To Reproduce
Steps to reproduce the behavior:
dbrouter.py
file to run ahistoricaluser
migration on a separate databasepython manage.py createsuperuser
)Expected behavior
I'd like to see a record in the
historicaluser
table (in the history database) that describes a user created in the operational database.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: