1 # -*- coding: utf-8 -*-
3 from datetime import datetime
8 from django.utils.translation import ugettext as _
11 from django.utils.encoding import force_unicode
14 from cPickle import loads, dumps
16 from pickle import loads, dumps
18 from copy import deepcopy
19 from base64 import b64encode, b64decode
20 from zlib import compress, decompress
22 from xml.sax import make_parser
23 from xml.sax.handler import ContentHandler
25 class SXTableHandler(ContentHandler):
26 def __init__(self, fname, callback):
31 self.fname = fname.lower()
32 self.callback = callback
34 def startElement(self, name, attrs):
35 if name.lower() == self.fname:
37 elif name.lower() == "row":
40 def characters(self, ch):
43 def endElement(self, name):
44 if name.lower() == self.fname:
46 elif name.lower() == "row":
47 self.callback(self.el_data)
53 self.el_data[name.lower()] = self.ch_data.strip()
58 def readTable(path, name, callback):
59 parser = make_parser()
60 handler = SXTableHandler(name, callback)
61 parser.setContentHandler(handler)
63 f = os.path.join(path, "%s.xml" % name)
67 def dbsafe_encode(value):
68 return force_unicode(b64encode(compress(dumps(deepcopy(value)))))
72 for node in el.childNodes:
73 if node.nodeType == node.TEXT_NODE:
77 msstrip = re.compile(r'^(.*)\.\d+')
79 noms = msstrip.match(ts)
83 return datetime(*time.strptime(ts, '%Y-%m-%dT%H:%M:%S')[0:6])
86 # return dict([(n.tagName.lower(), getText(n)) for n in el.childNodes if n.nodeType == el.ELEMENT_NODE])
88 #def readTable(dump, name):
89 # for e in minidom.parseString(dump.read("%s.xml" % name)).getElementsByTagName('row'):
91 #return [readEl(e) for e in minidom.parseString(dump.read("%s.xml" % name)).getElementsByTagName('row')]
93 google_accounts_lookup = re.compile(r'^https?://www.google.com/accounts/')
94 yahoo_accounts_lookup = re.compile(r'^https?://me.yahoo.com/a/')
97 re.compile(r'^https?://www.google.com/profiles/(?P<uname>\w+(\.\w+)*)/?$'),
98 re.compile(r'^https?://me.yahoo.com/(?P<uname>\w+(\.\w+)*)/?$'),
99 re.compile(r'^https?://openid.aol.com/(?P<uname>\w+(\.\w+)*)/?$'),
100 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).myopenid.com/?$'),
101 re.compile(r'^https?://flickr.com/(\w+/)*(?P<uname>\w+(\.\w+)*)/?$'),
102 re.compile(r'^https?://technorati.com/people/technorati/(?P<uname>\w+(\.\w+)*)/?$'),
103 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).wordpress.com/?$'),
104 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).blogspot.com/?$'),
105 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).livejournal.com/?$'),
106 re.compile(r'^https?://claimid.com/(?P<uname>\w+(\.\w+)*)/?$'),
107 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).pip.verisignlabs.com/?$'),
108 re.compile(r'^https?://getopenid.com/(?P<uname>\w+(\.\w+)*)/?$'),
109 re.compile(r'^https?://[\w\.]+/(\w+/)*(?P<uname>\w+(\.\w+)*)/?$'),
110 re.compile(r'^https?://(?P<uname>[\w\.]+)/?$'),
113 def final_username_attempt(sxu):
114 openid = sxu.get('openid', None)
117 if google_accounts_lookup.search(openid):
118 return UnknownGoogleUser(sxu.get('id'))
119 if yahoo_accounts_lookup.search(openid):
120 return UnknownYahooUser(sxu.get('id'))
122 for lookup in openid_lookups:
123 if lookup.search(openid):
124 return lookup.search(openid).group('uname')
126 return UnknownUser(sxu.get('id'))
128 class UnknownUser(object):
129 def __init__(self, id):
133 return _("user-%(id)s") % {'id': self._id}
135 def __unicode__(self):
136 return self.__str__()
138 def encode(self, *args):
139 return self.__str__()
141 class UnknownGoogleUser(UnknownUser):
143 return _("user-%(id)s (google)") % {'id': self._id}
145 class UnknownYahooUser(UnknownUser):
147 return _("user-%(id)s (yahoo)") % {'id': self._id}
150 class IdMapper(dict):
151 def __getitem__(self, key):
153 return super(IdMapper, self).get(key, 1)
155 def __setitem__(self, key, value):
156 super(IdMapper, self).__setitem__(int(key), int(value))
158 class IdIncrementer():
159 def __init__(self, initial):
165 openidre = re.compile('^https?\:\/\/')
166 def userimport(path, options):
170 uidmapper = IdMapper()
172 authenticated_user = options.get('authenticated_user', None)
173 owneruid = options.get('owneruid', None)
174 #check for empty values
181 if sxu.get('id') == '-1':
183 #print "\n".join(["%s : %s" % i for i in sxu.items()])
185 if int(sxu.get('id')) == int(owneruid):
186 if authenticated_user:
187 osqau = orm.User.objects.get(id=authenticated_user.id)
189 for assoc in orm.AuthKeyUserAssociation.objects.filter(user=osqau):
190 openids.add(assoc.key)
192 uidmapper[owneruid] = osqau.id
193 uidmapper[-1] = osqau.id
196 uidmapper[owneruid] = int(owneruid)
197 uidmapper[-1] = int(owneruid)
200 sxbadges = sxu.get('badgesummary', None)
201 badges = {'1':'0', '2':'0', '3':'0'}
204 badges.update(dict([b.split('=') for b in sxbadges.split()]))
207 username = unicode(sxu.get('displayname',
208 sxu.get('displaynamecleaned', sxu.get('realname', final_username_attempt(sxu)))))[:30]
210 if username in usernames:
211 #if options.get('mergesimilar', False) and sxu.get('email', 'INVALID') == user_by_name[username].email:
212 # osqau = user_by_name[username]
214 # uidmapper[sxu.get('id')] = osqau.id
220 totest = "%s %d" % (username[:29 - len(str(inc))], inc)
222 if not totest in usernames:
230 email = sxu.get('email', ''),
231 is_superuser = sxu.get('usertypeid') == '5',
232 is_staff = sxu.get('usertypeid') == '4',
234 date_joined = readTime(sxu.get('creationdate')),
235 last_seen = readTime(sxu.get('lastaccessdate')),
236 about = sxu.get('aboutme', ''),
237 date_of_birth = sxu.get('birthday', None) and readTime(sxu['birthday']) or None,
238 email_isvalid = int(sxu.get('usertypeid')) > 2,
239 website = sxu.get('websiteurl', ''),
240 reputation = int(sxu.get('reputation')),
241 gold = int(badges['1']),
242 silver = int(badges['2']),
243 bronze = int(badges['3']),
244 real_name = sxu.get('realname', '')[:30],
245 location = sxu.get('location', ''),
250 user_joins = orm.Action(
251 action_type = "userjoins",
252 action_date = osqau.date_joined,
257 rep = orm.ActionRepute(
260 date = osqau.date_joined,
266 orm.SubscriptionSettings.objects.get(user=osqau)
268 s = orm.SubscriptionSettings(user=osqau)
271 uidmapper[osqau.id] = osqau.id
273 new_about = sxu.get('aboutme', None)
274 if new_about and osqau.about != new_about:
276 osqau.about = "%s\n|\n%s" % (osqau.about, new_about)
278 osqau.about = new_about
280 osqau.username = sxu.get('displayname',
281 sxu.get('displaynamecleaned', sxu.get('realname', final_username_attempt(sxu))))
282 osqau.email = sxu.get('email', '')
283 osqau.reputation += int(sxu.get('reputation'))
284 osqau.gold += int(badges['1'])
285 osqau.silver += int(badges['2'])
286 osqau.bronze += int(badges['3'])
288 osqau.date_joined = readTime(sxu.get('creationdate'))
289 osqau.website = sxu.get('websiteurl', '')
290 osqau.date_of_birth = sxu.get('birthday', None) and readTime(sxu['birthday']) or None
291 osqau.location = sxu.get('location', '')
292 osqau.real_name = sxu.get('realname', '')
294 #merged_users.append(osqau.id)
297 usernames.append(osqau.username)
299 openid = sxu.get('openid', None)
300 if openid and openidre.match(openid) and (not openid in openids):
301 assoc = orm.AuthKeyUserAssociation(user=osqau, key=openid, provider="openidurl")
305 openidalt = sxu.get('openidalt', None)
306 if openidalt and openidre.match(openidalt) and (not openidalt in openids):
307 assoc = orm.AuthKeyUserAssociation(user=osqau, key=openidalt, provider="openidurl")
309 openids.add(openidalt)
311 readTable(path, "Users", callback)
313 if uidmapper[-1] == -1:
318 def tagsimport(dump, uidmap):
324 id = int(sxtag['id']),
325 name = sxtag['name'],
326 used_count = int(sxtag['count']),
327 created_by_id = uidmap[sxtag.get('userid', 1)],
331 tagmap[otag.name] = otag
333 readTable(dump, "Tags", callback)
337 def add_post_state(name, post, action):
338 if not "(%s)" % name in post.state_string:
339 post.state_string = "%s(%s)" % (post.state_string, name)
343 state = orm.NodeState.objects.get(node=post, state_type=name)
344 state.action = action
347 state = orm.NodeState(node=post, state_type=name, action=action)
350 def remove_post_state(name, post):
351 if "(%s)" % name in post.state_string:
353 state = orm.NodeState.objects.get(state_type=name, post=post)
357 post.state_string = "".join("(%s)" % s for s in re.findall('\w+', post.state_string) if s != name)
359 def postimport(dump, uidmap, tagmap):
362 def callback(sxpost):
363 nodetype = (sxpost.get('posttypeid') == '1') and "nodetype" or "answer"
366 node_type = nodetype,
368 added_at = readTime(sxpost['creationdate']),
369 body = sxpost['body'],
370 score = sxpost.get('score', 0),
371 author_id = sxpost.get('deletiondate', None) and 1 or uidmap[sxpost.get('owneruserid', 1)]
376 create_action = orm.Action(
377 action_type = (nodetype == "nodetype") and "ask" or "answer",
378 user_id = post.author_id,
380 action_date = post.added_at
385 if sxpost.get('lasteditoruserid', None):
386 revise_action = orm.Action(
387 action_type = "revise",
388 user_id = uidmap[sxpost.get('lasteditoruserid')],
390 action_date = readTime(sxpost['lasteditdate']),
394 post.last_edited = revise_action
396 if sxpost.get('communityowneddate', None):
397 wikify_action = orm.Action(
398 action_type = "wikify",
401 action_date = readTime(sxpost['communityowneddate'])
405 add_post_state("wiki", post, wikify_action)
407 if sxpost.get('lastactivityuserid', None):
408 post.last_activity_by_id = uidmap[sxpost['lastactivityuserid']]
409 post.last_activity_at = readTime(sxpost['lastactivitydate'])
411 if sxpost.get('posttypeid') == '1': #question
412 post.node_type = "question"
413 post.title = sxpost['title']
415 tagnames = sxpost['tags'].replace(u'ö', '-').replace(u'é', '').replace(u'à ', '')
416 post.tagnames = tagnames
418 post.extra_count = sxpost.get('viewcount', 0)
420 add_tags_to_post(post, tagmap)
423 post.parent_id = sxpost['parentid']
427 all.append(int(post.id))
428 create_and_activate_revision(post)
432 readTable(dump, "Posts", callback)
436 def comment_import(dump, uidmap, posts):
437 currid = IdIncrementer(max(posts))
444 node_type = "comment",
445 added_at = readTime(sxc['creationdate']),
446 author_id = uidmap[sxc.get('userid', 1)],
448 parent_id = sxc.get('postid'),
451 if sxc.get('deletiondate', None):
452 delete_action = orm.Action(
453 action_type = "delete",
454 user_id = uidmap[sxc['deletionuserid']],
455 action_date = readTime(sxc['deletiondate'])
458 oc.author_id = uidmap[sxc['deletionuserid']]
461 delete_action.node = oc
464 add_post_state("deleted", oc, delete_action)
466 oc.author_id = uidmap[sxc.get('userid', 1)]
469 create_action = orm.Action(
470 action_type = "comment",
471 user_id = oc.author_id,
473 action_date = oc.added_at
476 create_and_activate_revision(oc)
481 posts.append(int(oc.id))
482 mapping[int(sxc['id'])] = int(oc.id)
484 readTable(dump, "PostComments", callback)
485 return posts, mapping
488 def add_tags_to_post(post, tagmap):
489 tags = [tag for tag in [tagmap.get(name.strip()) for name in post.tagnames.split(u' ') if name] if tag]
490 post.tagnames = " ".join([t.name for t in tags]).strip()
494 def create_and_activate_revision(post):
495 rev = orm.NodeRevision(
496 author_id = post.author_id,
499 revised_at = post.added_at,
501 summary = 'Initial revision',
502 tagnames = post.tagnames,
507 post.active_revision_id = rev.id
510 def post_vote_import(dump, uidmap, posts):
513 def close_callback(r):
514 close_reasons[r['id']] = r['name']
516 readTable(dump, "CloseReasons", close_callback)
522 user_id=uidmap[sxv['userid']],
523 action_date = readTime(sxv['creationdate']),
526 if not int(sxv['postid']) in posts: return
527 node = orm.Node.objects.get(id=sxv['postid'])
530 if sxv['votetypeid'] == '1':
532 question = orm.Node.objects.get(id=answer.parent_id)
534 action.action_type = "acceptanswer"
539 question.extra_ref_id = answer.id
544 elif sxv['votetypeid'] in ('2', '3'):
545 if not (action.node.id, action.user_id) in user2vote:
546 user2vote.append((action.node.id, action.user_id))
548 action.action_type = (sxv['votetypeid'] == '2') and "voteup" or "votedown"
552 node_id = action.node.id,
553 user_id = action.user_id,
554 voted_at = action.action_date,
555 value = sxv['votetypeid'] == '2' and 1 or -1,
560 action.action_type = "unknown"
563 elif sxv['votetypeid'] in ('4', '12', '13'):
564 action.action_type = "flag"
569 user_id = action.user_id,
570 flagged_at = action.action_date,
577 elif sxv['votetypeid'] == '5':
578 action.action_type = "favorite"
581 elif sxv['votetypeid'] == '6':
582 action.action_type = "close"
583 action.extra = dbsafe_encode(close_reasons[sxv['comment']])
589 elif sxv['votetypeid'] == '7':
590 action.action_type = "unknown"
596 remove_post_state("closed", node)
598 elif sxv['votetypeid'] == '10':
599 action.action_type = "delete"
602 elif sxv['votetypeid'] == '11':
603 action.action_type = "unknown"
606 remove_post_state("deleted", node)
609 action.action_type = "unknown"
612 if sxv.get('targetrepchange', None):
613 rep = orm.ActionRepute(
615 date = action.action_date,
616 user_id = uidmap[sxv['targetuserid']],
617 value = int(sxv['targetrepchange'])
622 if sxv.get('voterrepchange', None):
623 rep = orm.ActionRepute(
625 date = action.action_date,
626 user_id = uidmap[sxv['userid']],
627 value = int(sxv['voterrepchange'])
632 if action.action_type in ("acceptanswer", "delete", "close"):
633 state = {"acceptanswer": "accepted", "delete": "deleted", "close": "closed"}[action.action_type]
634 add_post_state(state, node, action)
636 readTable(dump, "Posts2Votes", callback)
639 def comment_vote_import(dump, uidmap, comments):
644 if sxv['votetypeid'] == "2":
645 comment_id = comments[int(sxv['postcommentid'])]
646 user_id = uidmap[sxv['userid']]
648 if not (comment_id, user_id) in user2vote:
649 user2vote.append((comment_id, user_id))
652 action_type = "voteupcomment",
654 action_date = readTime(sxv['creationdate']),
660 node_id = comment_id,
662 voted_at = action.action_date,
669 if not comment_id in comments2score:
670 comments2score[comment_id] = 1
672 comments2score[comment_id] += 1
674 readTable(dump, "Comments2Votes", callback)
676 for cid, score in comments2score.items():
677 orm.Node.objects.filter(id=cid).update(score=score)
680 def badges_import(dump, uidmap, post_list):
685 sxbadges[int(b['id'])] = b
687 readTable(dump, "Badges", sxcallback)
689 obadges = dict([(b.cls, b) for b in orm.Badge.objects.all()])
690 user_badge_count = {}
694 for id, sxb in sxbadges.items():
695 cls = "".join(sxb['name'].replace('&', 'And').split(' '))
698 sx_to_osqa[id] = obadges[cls]
706 sx_to_osqa[id] = osqab
711 badge = sx_to_osqa[int(sxa['badgeid'])]
713 user_id = uidmap[sxa['userid']]
714 if not user_badge_count.get(user_id, None):
715 user_badge_count[user_id] = 0
718 action_type = "award",
720 action_date = readTime(sxa['date'])
726 user_id = uidmap[sxa['userid']],
728 node_id = post_list[user_badge_count[user_id]],
729 awarded_at = action.action_date,
734 badge.awarded_count += 1
735 user_badge_count[user_id] += 1
737 readTable(dump, "Users2Badges", callback)
739 for badge in obadges.values():
742 def save_setting(k, v):
744 kv = orm.KeyValue.objects.get(key=k)
747 kv = orm.KeyValue(key = k, value = v)
752 def pages_import(dump, currid):
753 currid = IdIncrementer(currid)
762 body = b64decode(sxp['value']),
763 extra = dbsafe_encode({
764 'path': sxp['url'][1:],
765 'mimetype': sxp['contenttype'],
766 'template': (sxp['usemaster'] == "true") and "default" or "none",
769 'sidebar_wrap': True,
770 'sidebar_render': "html",
776 create_and_activate_revision(page)
779 registry[sxp['url'][1:]] = page.id
781 create_action = orm.Action(
782 action_type = "newpage",
783 user_id = page.author_id,
789 if sxp['active'] == "true" and sxp['contenttype'] == "text/html":
790 pub_action = orm.Action(
791 action_type = "publish",
792 user_id = page.author_id,
797 add_post_state("published", page, pub_action)
799 readTable(dump, "FlatPages", callback)
801 save_setting('STATIC_PAGE_REGISTRY', dbsafe_encode(registry))
804 u'theme.html.name': 'APP_TITLE',
805 u'theme.html.footer': 'CUSTOM_FOOTER',
806 u'theme.html.sidebar': 'SIDEBAR_UPPER_TEXT',
807 u'theme.html.sidebar-low': 'SIDEBAR_LOWER_TEXT',
808 u'theme.html.welcome': 'APP_INTRO',
809 u'theme.html.head': 'CUSTOM_HEAD',
810 u'theme.html.header': 'CUSTOM_HEADER',
811 u'theme.css': 'CUSTOM_CSS',
822 def html_decode(html):
823 html = force_unicode(html)
825 for args in html_codes:
826 html = html.replace(*args)
831 def static_import(dump):
835 if unicode(set['name']) in sx2osqa_set_map:
836 save_setting(sx2osqa_set_map[set['name']], dbsafe_encode(html_decode(set['value'])))
838 sx_unknown[set['name']] = html_decode(set['value'])
840 readTable(dump, "ThemeTextResources", callback)
842 save_setting('SXIMPORT_UNKNOWN_SETS', dbsafe_encode(sx_unknown))
844 def disable_triggers():
845 from south.db import db
846 if db.backend_name == "postgres":
847 db.execute_many(PG_DISABLE_TRIGGERS)
848 db.commit_transaction()
849 db.start_transaction()
851 def enable_triggers():
852 from south.db import db
853 if db.backend_name == "postgres":
854 db.start_transaction()
855 db.execute_many(PG_ENABLE_TRIGGERS)
856 db.commit_transaction()
858 def reset_sequences():
859 from south.db import db
860 if db.backend_name == "postgres":
861 db.start_transaction()
862 db.execute_many(PG_SEQUENCE_RESETS)
863 db.commit_transaction()
866 from south.db import db
867 if db.backend_name == "postgres":
868 db.start_transaction()
869 db.execute_many("UPDATE forum_noderevision set id = id WHERE TRUE;")
870 db.commit_transaction()
873 def sximport(dump, options):
876 triggers_disabled = True
878 triggers_disabled = False
880 uidmap = userimport(dump, options)
881 tagmap = tagsimport(dump, uidmap)
884 posts = postimport(dump, uidmap, tagmap)
887 posts, comments = comment_import(dump, uidmap, posts)
890 post_vote_import(dump, uidmap, posts)
893 comment_vote_import(dump, uidmap, comments)
896 badges_import(dump, uidmap, posts)
898 pages_import(dump, max(posts))
902 from south.db import db
903 db.commit_transaction()
907 if triggers_disabled:
912 PG_DISABLE_TRIGGERS = """
913 ALTER table auth_user DISABLE TRIGGER ALL;
914 ALTER table auth_user_groups DISABLE TRIGGER ALL;
915 ALTER table auth_user_user_permissions DISABLE TRIGGER ALL;
916 ALTER table forum_keyvalue DISABLE TRIGGER ALL;
917 ALTER table forum_action DISABLE TRIGGER ALL;
918 ALTER table forum_actionrepute DISABLE TRIGGER ALL;
919 ALTER table forum_subscriptionsettings DISABLE TRIGGER ALL;
920 ALTER table forum_validationhash DISABLE TRIGGER ALL;
921 ALTER table forum_authkeyuserassociation DISABLE TRIGGER ALL;
922 ALTER table forum_tag DISABLE TRIGGER ALL;
923 ALTER table forum_markedtag DISABLE TRIGGER ALL;
924 ALTER table forum_node DISABLE TRIGGER ALL;
925 ALTER table forum_nodestate DISABLE TRIGGER ALL;
926 ALTER table forum_node_tags DISABLE TRIGGER ALL;
927 ALTER table forum_noderevision DISABLE TRIGGER ALL;
928 ALTER table forum_node_tags DISABLE TRIGGER ALL;
929 ALTER table forum_questionsubscription DISABLE TRIGGER ALL;
930 ALTER table forum_vote DISABLE TRIGGER ALL;
931 ALTER table forum_flag DISABLE TRIGGER ALL;
932 ALTER table forum_badge DISABLE TRIGGER ALL;
933 ALTER table forum_award DISABLE TRIGGER ALL;
934 ALTER table forum_openidnonce DISABLE TRIGGER ALL;
935 ALTER table forum_openidassociation DISABLE TRIGGER ALL;
938 PG_ENABLE_TRIGGERS = """
939 ALTER table auth_user ENABLE TRIGGER ALL;
940 ALTER table auth_user_groups ENABLE TRIGGER ALL;
941 ALTER table auth_user_user_permissions ENABLE TRIGGER ALL;
942 ALTER table forum_keyvalue ENABLE TRIGGER ALL;
943 ALTER table forum_action ENABLE TRIGGER ALL;
944 ALTER table forum_actionrepute ENABLE TRIGGER ALL;
945 ALTER table forum_subscriptionsettings ENABLE TRIGGER ALL;
946 ALTER table forum_validationhash ENABLE TRIGGER ALL;
947 ALTER table forum_authkeyuserassociation ENABLE TRIGGER ALL;
948 ALTER table forum_tag ENABLE TRIGGER ALL;
949 ALTER table forum_markedtag ENABLE TRIGGER ALL;
950 ALTER table forum_node ENABLE TRIGGER ALL;
951 ALTER table forum_nodestate ENABLE TRIGGER ALL;
952 ALTER table forum_node_tags ENABLE TRIGGER ALL;
953 ALTER table forum_noderevision ENABLE TRIGGER ALL;
954 ALTER table forum_node_tags ENABLE TRIGGER ALL;
955 ALTER table forum_questionsubscription ENABLE TRIGGER ALL;
956 ALTER table forum_vote ENABLE TRIGGER ALL;
957 ALTER table forum_flag ENABLE TRIGGER ALL;
958 ALTER table forum_badge ENABLE TRIGGER ALL;
959 ALTER table forum_award ENABLE TRIGGER ALL;
960 ALTER table forum_openidnonce ENABLE TRIGGER ALL;
961 ALTER table forum_openidassociation ENABLE TRIGGER ALL;
964 PG_SEQUENCE_RESETS = """
965 SELECT setval('"auth_user_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user";
966 SELECT setval('"auth_user_groups_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_groups";
967 SELECT setval('"auth_user_user_permissions_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_user_permissions";
968 SELECT setval('"forum_keyvalue_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_keyvalue";
969 SELECT setval('"forum_action_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_action";
970 SELECT setval('"forum_actionrepute_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_actionrepute";
971 SELECT setval('"forum_subscriptionsettings_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_subscriptionsettings";
972 SELECT setval('"forum_validationhash_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_validationhash";
973 SELECT setval('"forum_authkeyuserassociation_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_authkeyuserassociation";
974 SELECT setval('"forum_tag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_tag";
975 SELECT setval('"forum_markedtag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_markedtag";
976 SELECT setval('"forum_node_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node";
977 SELECT setval('"forum_nodestate_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_nodestate";
978 SELECT setval('"forum_node_tags_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node_tags";
979 SELECT setval('"forum_noderevision_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_noderevision";
980 SELECT setval('"forum_node_tags_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node_tags";
981 SELECT setval('"forum_questionsubscription_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_questionsubscription";
982 SELECT setval('"forum_vote_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_vote";
983 SELECT setval('"forum_flag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_flag";
984 SELECT setval('"forum_badge_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_badge";
985 SELECT setval('"forum_award_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_award";
986 SELECT setval('"forum_openidnonce_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_openidnonce";
987 SELECT setval('"forum_openidassociation_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_openidassociation";