add in addon purchase table for fast lookups (bug 680551)

This commit is contained in:
Andy McKay 2011-08-25 08:40:45 -07:00
Родитель c4dde13292
Коммит 2c78fa152d
2 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -3,8 +3,10 @@ from django.db import models
from translations.fields import TranslatedField
from addons.models import Addon
import amo
import amo.models
from users.models import UserProfile
import commonware.log
from jinja2.filters import do_dictsort
@ -47,3 +49,14 @@ class PriceCurrency(amo.models.ModelBase):
def __unicode__(self):
return u'%s, %s: %s' % (self.tier.name, self.currency, self.price)
class AddonPurchase(amo.models.ModelBase):
addon = models.ForeignKey(Addon)
user = models.ForeignKey(UserProfile)
class Meta:
db_table = 'addon_purchase'
def __unicode__(self):
return u'%s: %s' % (self.addon, self.user)

Просмотреть файл

@ -0,0 +1,13 @@
CREATE TABLE `addon_purchase` (
`id` int(11) unsigned AUTO_INCREMENT NOT NULL PRIMARY KEY,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
`addon_id` int(11) unsigned NOT NULL,
`user_id` int(11) unsigned NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `addon_purchase` ADD CONSTRAINT `addon_id_refs_addon_purchase` FOREIGN KEY (`addon_id`) REFERENCES `addons` (`id`);
ALTER TABLE `addon_purchase` ADD CONSTRAINT `user_id_refs_addon_purchase` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);
CREATE INDEX `addon_purchase_addon_id_idx` ON `addon_purchase` (`addon_id`);
CREATE INDEX `addon_purchase_user_id_idx` ON `addon_purchase` (`user_id`);