Closed clearclaw closed 9 years ago
Oh....Yes, I did a stupid.
Hi,
Glad you figured it out, but could you please elaborate a little bit more on this topic, what was the error on your side. That can probably help someone reading this issue in the future.
Thanks.
Will help me now! It seems that I'm doing the same stupid thing... EDIT more info: It seems that for some reason I have no triggers on the target DB: SHOW TRIGGERS from enastatsng; Empty set (0.00 sec)
Is this normal?
@oriolj Can you please provide more info about your current setup. If you are on MySQL then it's normal that you don't have any triggers because MySQL partitioning implementation in Architect doesn't use triggers because MySQL doesn't allow dynamic SQL inside triggers/trigger functions. If you are on PostgreSQL then it's not normal that you don't have any triggers. Any way, please provide more info about your environment and steps you have done and I'll try to see where the error is. @clearclaw ping, if you remember what was the error on your side, we would appreciate your help. Thanks.
I'm using MariaDB 10.0.21, here's my process:
create database enastatsng CHARACTER SET utf8; (grant permissions commands)
$ manage.py migrate $ export DJANGO_SETTINGS_MODULE=EnaStats.settings $ architect partition --module stats.models /home/oriol/venvs/enastats/lib/python2.7/site-packages/django/db/backends/mysql/base.py:124: Warning: Table 'mysql.index_stats' doesn't exist return self.cursor.execute(query, args) architect partition: result: successfully (re)configured the database for the following models: OriginalStatRecord
The OriginalStat record model: @architect.install('partition', type='range', subtype='date', constraint='month', column='orig_datetime_start') class OriginalStatRecord(models.Model): [...] orig_datetime_start = models.DateTimeField() [...]
Now if I go to mysql console and type:
use enastatsng; show create table stats_originalstatrecord; +--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | stats_originalstatrecord | CREATE TABLE
stats_originalstatrecord
( [...]generated_datetime_start
datetime NOT NULL, [...] PRIMARY KEY (orig_datetime_start
), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 /!50100 PARTITION BY RANGE (TO_DAYS(orig_datetime_start)) (PARTITION stats_originalstatrecord_y0000m00 VALUES LESS THAN (0) ENGINE = InnoDB) / | +--------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
Thanks!!
@oriolj Sorry for making you wait for so long, but I can't reproduce your problem here, but I have a theory. Are you trying to insert new objects in a bulk, e.g.:
Document.objects.bulk_create([
Document(name='foo', created=datetime.datetime(2014, 4, 15, 18, 44, 23)),
Document(name='bar', created=datetime.datetime(2014, 5, 15, 18, 44, 23)),
])
If yes, that won't work, because bulk_create
method in Django doesn't call save()
model method which Architect relies on for MySQL's table partitioning implementation. But the simple inserts like this
Document.objects.create(name='foo', created=datetime.datetime(2014, 4, 15, 18, 44, 23))
Document.objects.create(name='bar', created=datetime.datetime(2014, 5, 15, 18, 44, 23))
should work very well.
@maxtepkeev you are totally right! Thanks!
DJango 1.7, MySQL (RDS) 5.6, latest Architect.
The model prefix:
./manage migrate run cleanly. New database. Empty table.
What MySQL has to think about it:
But on an attempted write into the table:
Suspect I'm doing something stupid?