mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Add migration script for surveys
In passing, make answers up to 500 characters, because that's required to perform the migration of existing ones...
This commit is contained in:
@ -17,15 +17,15 @@ class SurveyAnswerValues(object):
|
|||||||
self.votespercent = votespercent
|
self.votespercent = votespercent
|
||||||
|
|
||||||
class Survey(PgModel, models.Model):
|
class Survey(PgModel, models.Model):
|
||||||
question = models.CharField(max_length=100, null=False, blank=False)
|
question = models.CharField(max_length=500, null=False, blank=False)
|
||||||
opt1 = models.CharField(max_length=100, null=False, blank=False)
|
opt1 = models.CharField(max_length=500, null=False, blank=False)
|
||||||
opt2 = models.CharField(max_length=100, null=False, blank=False)
|
opt2 = models.CharField(max_length=500, null=False, blank=False)
|
||||||
opt3 = models.CharField(max_length=100, null=False, blank=True)
|
opt3 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
opt4 = models.CharField(max_length=100, null=False, blank=True)
|
opt4 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
opt5 = models.CharField(max_length=100, null=False, blank=True)
|
opt5 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
opt6 = models.CharField(max_length=100, null=False, blank=True)
|
opt6 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
opt7 = models.CharField(max_length=100, null=False, blank=True)
|
opt7 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
opt8 = models.CharField(max_length=100, null=False, blank=True)
|
opt8 = models.CharField(max_length=500, null=False, blank=True)
|
||||||
posted = models.DateTimeField(null=False, default=datetime.now)
|
posted = models.DateTimeField(null=False, default=datetime.now)
|
||||||
current = models.BooleanField(null=False, default=False)
|
current = models.BooleanField(null=False, default=False)
|
||||||
|
|
||||||
|
@ -152,4 +152,19 @@ products.url,
|
|||||||
description, COALESCE(price,'') , products.lastconfirmed
|
description, COALESCE(price,'') , products.lastconfirmed
|
||||||
FROM oldweb.products
|
FROM oldweb.products
|
||||||
INNER JOIN oldweb.organisations oo ON publisher=oo.id
|
INNER JOIN oldweb.organisations oo ON publisher=oo.id
|
||||||
INNER JOIN oldweb.product_categories ON category=product_categories.id;
|
INNER JOIN oldweb.product_categories ON category=product_categories.id;
|
||||||
|
|
||||||
|
|
||||||
|
-- Surveys
|
||||||
|
TRUNCATE TABLE survey_surveyanswer CASCADE;
|
||||||
|
TRUNCATE TABLE survey_survey CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO survey_survey (id, question, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8, posted, current)
|
||||||
|
SELECT surveyid, question, coalesce(opt1,''), coalesce(opt2,''), coalesce(opt3,''), coalesce(opt4,''), coalesce(opt5,''), coalesce(opt6,''), coalesce(opt7,''), coalesce(opt8,''), modified, current
|
||||||
|
FROM oldweb.survey_questions INNER JOIN oldweb.surveys ON surveys.id=survey_questions.surveyid;
|
||||||
|
|
||||||
|
INSERT INTO survey_surveyanswer (survey_id, tot1, tot2, tot3, tot4, tot5, tot6, tot7, tot8)
|
||||||
|
SELECT id, tot1, tot2, tot3, tot4, tot5, tot6, tot7, tot8
|
||||||
|
FROM oldweb.surveys;
|
||||||
|
|
||||||
|
SELECT setval('survey_survey_id_seq', max(id)) FROM survey_survey;
|
||||||
|
Reference in New Issue
Block a user