1 # -*- coding: utf-8 -*-
3 from xml.dom import minidom
4 from datetime import datetime, timedelta
9 from django.utils.translation import ugettext as _
10 from django.template.defaultfilters import slugify
11 from forum.models.utils import dbsafe_encode
14 from django.utils.encoding import force_unicode
17 from cPickle import loads, dumps
19 from pickle import loads, dumps
21 from copy import deepcopy
22 from base64 import b64encode, b64decode
23 from zlib import compress, decompress
25 from xml.sax import make_parser
26 from xml.sax.handler import ContentHandler
28 class SXTableHandler(ContentHandler):
29 def __init__(self, fname, callback):
34 self.fname = fname.lower()
35 self.callback = callback
37 def startElement(self, name, attrs):
38 if name.lower() == self.fname:
40 elif name.lower() == "row":
43 def characters(self, ch):
46 def endElement(self, name):
47 if name.lower() == self.fname:
49 elif name.lower() == "row":
50 self.callback(self.el_data)
56 self.el_data[name.lower()] = self.ch_data.strip()
61 def readTable(path, name, callback):
62 parser = make_parser()
63 handler = SXTableHandler(name, callback)
64 parser.setContentHandler(handler)
66 f = os.path.join(path, "%s.xml" % name)
70 def dbsafe_encode(value):
71 return force_unicode(b64encode(compress(dumps(deepcopy(value)))))
75 for node in el.childNodes:
76 if node.nodeType == node.TEXT_NODE:
80 msstrip = re.compile(r'^(.*)\.\d+')
82 noms = msstrip.match(ts)
86 return datetime(*time.strptime(ts, '%Y-%m-%dT%H:%M:%S')[0:6])
89 # return dict([(n.tagName.lower(), getText(n)) for n in el.childNodes if n.nodeType == el.ELEMENT_NODE])
91 #def readTable(dump, name):
92 # for e in minidom.parseString(dump.read("%s.xml" % name)).getElementsByTagName('row'):
94 #return [readEl(e) for e in minidom.parseString(dump.read("%s.xml" % name)).getElementsByTagName('row')]
96 google_accounts_lookup = re.compile(r'^https?://www.google.com/accounts/')
97 yahoo_accounts_lookup = re.compile(r'^https?://me.yahoo.com/a/')
100 re.compile(r'^https?://www.google.com/profiles/(?P<uname>\w+(\.\w+)*)/?$'),
101 re.compile(r'^https?://me.yahoo.com/(?P<uname>\w+(\.\w+)*)/?$'),
102 re.compile(r'^https?://openid.aol.com/(?P<uname>\w+(\.\w+)*)/?$'),
103 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).myopenid.com/?$'),
104 re.compile(r'^https?://flickr.com/(\w+/)*(?P<uname>\w+(\.\w+)*)/?$'),
105 re.compile(r'^https?://technorati.com/people/technorati/(?P<uname>\w+(\.\w+)*)/?$'),
106 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).wordpress.com/?$'),
107 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).blogspot.com/?$'),
108 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).livejournal.com/?$'),
109 re.compile(r'^https?://claimid.com/(?P<uname>\w+(\.\w+)*)/?$'),
110 re.compile(r'^https?://(?P<uname>\w+(\.\w+)*).pip.verisignlabs.com/?$'),
111 re.compile(r'^https?://getopenid.com/(?P<uname>\w+(\.\w+)*)/?$'),
112 re.compile(r'^https?://[\w\.]+/(\w+/)*(?P<uname>\w+(\.\w+)*)/?$'),
113 re.compile(r'^https?://(?P<uname>[\w\.]+)/?$'),
116 def final_username_attempt(sxu):
117 openid = sxu.get('openid', None)
120 if google_accounts_lookup.search(openid):
121 return UnknownGoogleUser(sxu.get('id'))
122 if yahoo_accounts_lookup.search(openid):
123 return UnknownYahooUser(sxu.get('id'))
125 for lookup in openid_lookups:
126 if lookup.search(openid):
127 return lookup.search(openid).group('uname')
129 return UnknownUser(sxu.get('id'))
131 class UnknownUser(object):
132 def __init__(self, id):
136 return _("user-%(id)s") % {'id': self._id}
138 def __unicode__(self):
139 return self.__str__()
141 def encode(self, *args):
142 return self.__str__()
144 class UnknownGoogleUser(UnknownUser):
146 return _("user-%(id)s (google)") % {'id': self._id}
148 class UnknownYahooUser(UnknownUser):
150 return _("user-%(id)s (yahoo)") % {'id': self._id}
153 class IdMapper(dict):
154 def __getitem__(self, key):
156 return super(IdMapper, self).get(key, 1)
158 def __setitem__(self, key, value):
159 super(IdMapper, self).__setitem__(int(key), int(value))
161 class IdIncrementer():
162 def __init__(self, initial):
168 openidre = re.compile('^https?\:\/\/')
169 def userimport(path, options):
170 #users = readTable(dump, "Users")
173 uidmapper = IdMapper()
176 owneruid = options.get('owneruid', None)
177 #check for empty values
184 if sxu.get('id') == '-1':
186 #print "\n".join(["%s : %s" % i for i in sxu.items()])
187 if int(sxu.get('id')) == int(owneruid):
188 osqau = orm.User.objects.get(id=1)
189 uidmapper[owneruid] = 1
193 username = sxu.get('displayname',
194 sxu.get('displaynamecleaned', sxu.get('realname', final_username_attempt(sxu))))
196 if not isinstance(username, UnknownUser) and username in user_by_name:
197 #if options.get('mergesimilar', False) and sxu.get('email', 'INVALID') == user_by_name[username].email:
198 # osqau = user_by_name[username]
200 # uidmapper[sxu.get('id')] = osqau.id
203 while ("%s %d" % (username, inc)) in user_by_name:
206 username = "%s %d" % (username, inc)
208 sxbadges = sxu.get('badgesummary', None)
209 badges = {'1':'0', '2':'0', '3':'0'}
212 badges.update(dict([b.split('=') for b in sxbadges.split()]))
217 username = unicode(username),
219 email = sxu.get('email', ''),
220 is_superuser = sxu.get('usertypeid') == '5',
221 is_staff = sxu.get('usertypeid') == '4',
223 date_joined = readTime(sxu.get('creationdate')),
224 last_seen = readTime(sxu.get('lastaccessdate')),
225 about = sxu.get('aboutme', ''),
226 date_of_birth = sxu.get('birthday', None) and readTime(sxu['birthday']) or None,
227 email_isvalid = int(sxu.get('usertypeid')) > 2,
228 website = sxu.get('websiteurl', ''),
229 reputation = int(sxu.get('reputation')),
230 gold = int(badges['1']),
231 silver = int(badges['2']),
232 bronze = int(badges['3']),
233 real_name = sxu.get('realname', ''),
234 location = sxu.get('location', ''),
239 user_joins = orm.Action(
240 action_type = "userjoins",
241 action_date = osqau.date_joined,
246 rep = orm.ActionRepute(
249 date = osqau.date_joined,
255 orm.SubscriptionSettings.objects.get(user=osqau)
257 s = orm.SubscriptionSettings(user=osqau)
260 uidmapper[osqau.id] = osqau.id
262 new_about = sxu.get('aboutme', None)
263 if new_about and osqau.about != new_about:
265 osqau.about = "%s\n|\n%s" % (osqau.about, new_about)
267 osqau.about = new_about
269 osqau.username = sxu.get('displayname',
270 sxu.get('displaynamecleaned', sxu.get('realname', final_username_attempt(sxu))))
271 osqau.email = sxu.get('email', '')
272 osqau.reputation += int(sxu.get('reputation'))
273 osqau.gold += int(badges['1'])
274 osqau.silver += int(badges['2'])
275 osqau.bronze += int(badges['3'])
277 osqau.date_joined = readTime(sxu.get('creationdate'))
278 osqau.website = sxu.get('websiteurl', '')
279 osqau.date_of_birth = sxu.get('birthday', None) and readTime(sxu['birthday']) or None
280 osqau.location = sxu.get('location', '')
281 osqau.real_name = sxu.get('realname', '')
283 #merged_users.append(osqau.id)
286 user_by_name[osqau.username] = osqau
288 openid = sxu.get('openid', None)
289 if openid and openidre.match(openid):
290 assoc = orm.AuthKeyUserAssociation(user=osqau, key=openid, provider="openidurl")
293 readTable(path, "Users", callback)
295 if uidmapper[-1] == -1:
300 def tagsimport(dump, uidmap):
301 #tags = readTable(dump, "Tags")
307 id = int(sxtag['id']),
308 name = sxtag['name'],
309 used_count = int(sxtag['count']),
310 created_by_id = uidmap[sxtag.get('userid', 1)],
314 tagmap[otag.name] = otag
316 readTable(dump, "Tags", callback)
320 def add_post_state(name, post, action):
321 if not "(%s)" % name in post.state_string:
322 post.state_string = "%s(%s)" % (post.state_string, name)
326 state = orm.NodeState.objects.get(node=post, state_type=name)
327 state.action = action
330 state = orm.NodeState(node=post, state_type=name, action=action)
333 def remove_post_state(name, post):
334 if "(%s)" % name in post.state_string:
336 state = orm.NodeState.objects.get(state_type=name, post=post)
340 post.state_string = "".join("(%s)" % s for s in re.findall('\w+', post.state_string) if s != name)
342 def postimport(dump, uidmap, tagmap):
347 #for h in readTable(dump, "PostHistory"):
348 # if not history.get(h.get('postid'), None):
349 # history[h.get('postid')] = []
351 # history[h.get('postid')].append(h)
353 #posts = readTable(dump, "Posts")
355 def callback(sxpost):
356 nodetype = (sxpost.get('posttypeid') == '1') and "nodetype" or "answer"
359 node_type = nodetype,
361 added_at = readTime(sxpost['creationdate']),
362 body = sxpost['body'],
363 score = sxpost.get('score', 0),
364 author_id = sxpost.get('deletiondate', None) and 1 or uidmap[sxpost.get('owneruserid', 1)]
369 create_action = orm.Action(
370 action_type = (nodetype == "nodetype") and "ask" or "answer",
371 user_id = post.author_id,
373 action_date = post.added_at
378 if sxpost.get('lasteditoruserid', None):
379 revise_action = orm.Action(
380 action_type = "revise",
381 user_id = uidmap[sxpost.get('lasteditoruserid')],
383 action_date = readTime(sxpost['lasteditdate']),
387 post.last_edited = revise_action
389 if sxpost.get('communityowneddate', None):
390 wikify_action = orm.Action(
391 action_type = "wikify",
394 action_date = readTime(sxpost['communityowneddate'])
398 add_post_state("wiki", post, wikify_action)
400 if sxpost.get('lastactivityuserid', None):
401 post.last_activity_by_id = uidmap[sxpost['lastactivityuserid']]
402 post.last_activity_at = readTime(sxpost['lastactivitydate'])
404 if sxpost.get('posttypeid') == '1': #question
405 post.node_type = "question"
406 post.title = sxpost['title']
408 tagnames = sxpost['tags'].replace(u'ö', '-').replace(u'é', '').replace(u'à ', '')
409 post.tagnames = tagnames
411 post.extra_count = sxpost.get('viewcount', 0)
413 add_tags_to_post(post, tagmap)
416 post.parent_id = sxpost['parentid']
420 all.append(int(post.id))
424 readTable(dump, "Posts", callback)
428 def comment_import(dump, uidmap, posts):
429 #comments = readTable(dump, "PostComments")
430 currid = IdIncrementer(max(posts))
437 node_type = "comment",
438 added_at = readTime(sxc['creationdate']),
439 author_id = uidmap[sxc.get('userid', 1)],
441 parent_id = sxc.get('postid'),
444 if sxc.get('deletiondate', None):
445 delete_action = orm.Action(
446 action_type = "delete",
447 user_id = uidmap[sxc['deletionuserid']],
448 action_date = readTime(sxc['deletiondate'])
451 oc.author_id = uidmap[sxc['deletionuserid']]
454 delete_action.node = oc
457 add_post_state("deleted", oc, delete_action)
459 oc.author_id = uidmap[sxc.get('userid', 1)]
462 create_action = orm.Action(
463 action_type = "comment",
464 user_id = oc.author_id,
466 action_date = oc.added_at
472 posts.append(int(oc.id))
473 mapping[int(sxc['id'])] = int(oc.id)
475 readTable(dump, "PostComments", callback)
476 return posts, mapping
479 def add_tags_to_post(post, tagmap):
480 tags = [tag for tag in [tagmap.get(name.strip()) for name in post.tagnames.split(u' ') if name] if tag]
481 post.tagnames = " ".join([t.name for t in tags]).strip()
483 create_and_activate_revision(post)
486 def create_and_activate_revision(post):
487 rev = orm.NodeRevision(
488 author_id = post.author_id,
491 revised_at = post.added_at,
493 summary = 'Initial revision',
494 tagnames = post.tagnames,
499 post.active_revision_id = rev.id
502 def post_vote_import(dump, uidmap, posts):
503 #votes = readTable(dump, "Posts2Votes")
506 def close_callback(r):
507 close_reasons[r['id']] = r['name']
509 readTable(dump, "CloseReasons", close_callback)
515 user_id=uidmap[sxv['userid']],
516 action_date = readTime(sxv['creationdate']),
519 if not int(sxv['postid']) in posts: return
520 node = orm.Node.objects.get(id=sxv['postid'])
523 if sxv['votetypeid'] == '1':
525 question = orm.Node.objects.get(id=answer.parent_id)
527 action.action_type = "acceptanswer"
532 question.extra_ref_id = answer.id
537 elif sxv['votetypeid'] in ('2', '3'):
538 if not (action.node.id, action.user_id) in user2vote:
539 user2vote.append((action.node.id, action.user_id))
541 action.action_type = (sxv['votetypeid'] == '2') and "voteup" or "votedown"
545 node_id = action.node.id,
546 user_id = action.user_id,
547 voted_at = action.action_date,
548 value = sxv['votetypeid'] == '2' and 1 or -1,
553 action.action_type = "unknown"
556 elif sxv['votetypeid'] in ('4', '12', '13'):
557 action.action_type = "flag"
562 user_id = action.user_id,
563 flagged_at = action.action_date,
570 elif sxv['votetypeid'] == '5':
571 action.action_type = "favorite"
574 elif sxv['votetypeid'] == '6':
575 action.action_type = "close"
576 action.extra = dbsafe_encode(close_reasons[sxv['comment']])
582 elif sxv['votetypeid'] == '7':
583 action.action_type = "unknown"
589 remove_post_state("closed", node)
591 elif sxv['votetypeid'] == '10':
592 action.action_type = "delete"
595 elif sxv['votetypeid'] == '11':
596 action.action_type = "unknown"
599 remove_post_state("deleted", node)
602 action.action_type = "unknown"
605 if sxv.get('targetrepchange', None):
606 rep = orm.ActionRepute(
608 date = action.action_date,
609 user_id = uidmap[sxv['targetuserid']],
610 value = int(sxv['targetrepchange'])
615 if sxv.get('voterrepchange', None):
616 rep = orm.ActionRepute(
618 date = action.action_date,
619 user_id = uidmap[sxv['userid']],
620 value = int(sxv['voterrepchange'])
625 if action.action_type in ("acceptanswer", "delete", "close"):
626 state = {"acceptanswer": "accepted", "delete": "deleted", "close": "closed"}[action.action_type]
627 add_post_state(state, node, action)
629 readTable(dump, "Posts2Votes", callback)
632 def comment_vote_import(dump, uidmap, comments):
633 #votes = readTable(dump, "Comments2Votes")
638 if sxv['votetypeid'] == "2":
639 comment_id = comments[int(sxv['postcommentid'])]
640 user_id = uidmap[sxv['userid']]
642 if not (comment_id, user_id) in user2vote:
643 user2vote.append((comment_id, user_id))
646 action_type = "voteupcomment",
648 action_date = readTime(sxv['creationdate']),
654 node_id = comment_id,
656 voted_at = action.action_date,
663 if not comment_id in comments2score:
664 comments2score[comment_id] = 1
666 comments2score[comment_id] += 1
668 readTable(dump, "Comments2Votes", callback)
670 for cid, score in comments2score.items():
671 orm.Node.objects.filter(id=cid).update(score=score)
674 def badges_import(dump, uidmap, post_list):
675 #node_ctype = orm['contenttypes.contenttype'].objects.get(name='node')
680 sxbadges[int(b['id'])] = b
682 readTable(dump, "Badges", sxcallback)
684 obadges = dict([(b.cls, b) for b in orm.Badge.objects.all()])
685 user_badge_count = {}
689 for id, sxb in sxbadges.items():
690 cls = "".join(sxb['name'].replace('&', 'And').split(' '))
693 sx_to_osqa[id] = obadges[cls]
701 sx_to_osqa[id] = osqab
706 badge = sx_to_osqa[int(sxa['badgeid'])]
708 user_id = uidmap[sxa['userid']]
709 if not user_badge_count.get(user_id, None):
710 user_badge_count[user_id] = 0
713 action_type = "award",
715 action_date = readTime(sxa['date'])
721 user_id = uidmap[sxa['userid']],
723 node_id = post_list[user_badge_count[user_id]],
724 awarded_at = action.action_date,
729 badge.awarded_count += 1
730 user_badge_count[user_id] += 1
732 readTable(dump, "Users2Badges", callback)
734 for badge in obadges.values():
737 def pages_import(dump, currid):
738 currid = IdIncrementer(currid)
740 #sx_pages = readTable(dump, "FlatPages")
748 body = b64decode(sxp['value']),
749 extra = dbsafe_encode({
750 'path': sxp['url'][1:],
751 'mimetype': sxp['contenttype'],
752 'template': (sxp['usemaster'] == "true") and "default" or "none",
755 'sidebar_wrap': True,
756 'sidebar_render': "html",
763 registry[sxp['url'][1:]] = page.id
765 create_action = orm.Action(
766 action_type = "newpage",
767 user_id = page.author_id,
773 if sxp['active'] == "true" and sxp['contenttype'] == "text/html":
774 pub_action = orm.Action(
775 action_type = "publish",
776 user_id = page.author_id,
781 add_post_state("published", page, pub_action)
783 readTable(dump, "FlatPages", callback)
785 kv = orm.KeyValue(key='STATIC_PAGE_REGISTRY', value=dbsafe_encode(registry))
789 u'theme.html.name': 'APP_TITLE',
790 u'theme.html.footer': 'CUSTOM_FOOTER',
791 u'theme.html.sidebar': 'SIDEBAR_UPPER_TEXT',
792 u'theme.html.sidebar-low': 'SIDEBAR_LOWER_TEXT',
793 u'theme.html.welcome': 'APP_INTRO',
794 u'theme.html.head': 'CUSTOM_HEAD',
795 u'theme.html.header': 'CUSTOM_HEADER',
796 u'theme.css': 'CUSTOM_CSS',
807 def html_decode(html):
808 html = force_unicode(html)
810 for args in html_codes:
811 html = html.replace(*args)
816 def static_import(dump):
817 #sx_sets = readTable(dump, "ThemeTextResources")
821 if unicode(set['name']) in sx2osqa_set_map:
823 key = sx2osqa_set_map[set['name']],
824 value = dbsafe_encode(html_decode(set['value']))
829 sx_unknown[set['name']] = html_decode(set['value'])
831 readTable(dump, "ThemeTextResources", callback)
833 unknown = orm.KeyValue(key='SXIMPORT_UNKNOWN_SETS', value=dbsafe_encode(sx_unknown))
836 def disable_triggers():
837 from south.db import db
838 if db.backend_name == "postgres":
839 db.execute_many(PG_DISABLE_TRIGGERS)
840 db.commit_transaction()
841 db.start_transaction()
843 def enable_triggers():
844 from south.db import db
845 if db.backend_name == "postgres":
846 db.start_transaction()
847 db.execute_many(PG_ENABLE_TRIGGERS)
848 db.commit_transaction()
850 def reset_sequences():
851 from south.db import db
852 if db.backend_name == "postgres":
853 db.start_transaction()
854 db.execute_many(PG_SEQUENCE_RESETS)
855 db.commit_transaction()
858 def sximport(dump, options):
860 uidmap = userimport(dump, options)
861 tagmap = tagsimport(dump, uidmap)
864 posts = postimport(dump, uidmap, tagmap)
867 posts, comments = comment_import(dump, uidmap, posts)
870 post_vote_import(dump, uidmap, posts)
873 comment_vote_import(dump, uidmap, comments)
876 badges_import(dump, uidmap, posts)
878 pages_import(dump, max(posts))
882 from south.db import db
883 db.commit_transaction()
889 PG_DISABLE_TRIGGERS = """
890 ALTER table auth_user DISABLE TRIGGER ALL;
891 ALTER table auth_user_groups DISABLE TRIGGER ALL;
892 ALTER table auth_user_user_permissions DISABLE TRIGGER ALL;
893 ALTER table forum_keyvalue DISABLE TRIGGER ALL;
894 ALTER table forum_action DISABLE TRIGGER ALL;
895 ALTER table forum_actionrepute DISABLE TRIGGER ALL;
896 ALTER table forum_subscriptionsettings DISABLE TRIGGER ALL;
897 ALTER table forum_validationhash DISABLE TRIGGER ALL;
898 ALTER table forum_authkeyuserassociation DISABLE TRIGGER ALL;
899 ALTER table forum_tag DISABLE TRIGGER ALL;
900 ALTER table forum_markedtag DISABLE TRIGGER ALL;
901 ALTER table forum_node DISABLE TRIGGER ALL;
902 ALTER table forum_nodestate DISABLE TRIGGER ALL;
903 ALTER table forum_node_tags DISABLE TRIGGER ALL;
904 ALTER table forum_noderevision DISABLE TRIGGER ALL;
905 ALTER table forum_node_tags DISABLE TRIGGER ALL;
906 ALTER table forum_questionsubscription DISABLE TRIGGER ALL;
907 ALTER table forum_vote DISABLE TRIGGER ALL;
908 ALTER table forum_flag DISABLE TRIGGER ALL;
909 ALTER table forum_badge DISABLE TRIGGER ALL;
910 ALTER table forum_award DISABLE TRIGGER ALL;
911 ALTER table forum_openidnonce DISABLE TRIGGER ALL;
912 ALTER table forum_openidassociation DISABLE TRIGGER ALL;
915 PG_ENABLE_TRIGGERS = """
916 ALTER table auth_user ENABLE TRIGGER ALL;
917 ALTER table auth_user_groups ENABLE TRIGGER ALL;
918 ALTER table auth_user_user_permissions ENABLE TRIGGER ALL;
919 ALTER table forum_keyvalue ENABLE TRIGGER ALL;
920 ALTER table forum_action ENABLE TRIGGER ALL;
921 ALTER table forum_actionrepute ENABLE TRIGGER ALL;
922 ALTER table forum_subscriptionsettings ENABLE TRIGGER ALL;
923 ALTER table forum_validationhash ENABLE TRIGGER ALL;
924 ALTER table forum_authkeyuserassociation ENABLE TRIGGER ALL;
925 ALTER table forum_tag ENABLE TRIGGER ALL;
926 ALTER table forum_markedtag ENABLE TRIGGER ALL;
927 ALTER table forum_node ENABLE TRIGGER ALL;
928 ALTER table forum_nodestate ENABLE TRIGGER ALL;
929 ALTER table forum_node_tags ENABLE TRIGGER ALL;
930 ALTER table forum_noderevision ENABLE TRIGGER ALL;
931 ALTER table forum_node_tags ENABLE TRIGGER ALL;
932 ALTER table forum_questionsubscription ENABLE TRIGGER ALL;
933 ALTER table forum_vote ENABLE TRIGGER ALL;
934 ALTER table forum_flag ENABLE TRIGGER ALL;
935 ALTER table forum_badge ENABLE TRIGGER ALL;
936 ALTER table forum_award ENABLE TRIGGER ALL;
937 ALTER table forum_openidnonce ENABLE TRIGGER ALL;
938 ALTER table forum_openidassociation ENABLE TRIGGER ALL;
941 PG_SEQUENCE_RESETS = """
942 SELECT setval('"auth_user_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user";
943 SELECT setval('"auth_user_groups_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_groups";
944 SELECT setval('"auth_user_user_permissions_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_user_permissions";
945 SELECT setval('"forum_keyvalue_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_keyvalue";
946 SELECT setval('"forum_action_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_action";
947 SELECT setval('"forum_actionrepute_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_actionrepute";
948 SELECT setval('"forum_subscriptionsettings_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_subscriptionsettings";
949 SELECT setval('"forum_validationhash_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_validationhash";
950 SELECT setval('"forum_authkeyuserassociation_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_authkeyuserassociation";
951 SELECT setval('"forum_tag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_tag";
952 SELECT setval('"forum_markedtag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_markedtag";
953 SELECT setval('"forum_node_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node";
954 SELECT setval('"forum_nodestate_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_nodestate";
955 SELECT setval('"forum_node_tags_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node_tags";
956 SELECT setval('"forum_noderevision_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_noderevision";
957 SELECT setval('"forum_node_tags_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_node_tags";
958 SELECT setval('"forum_questionsubscription_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_questionsubscription";
959 SELECT setval('"forum_vote_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_vote";
960 SELECT setval('"forum_flag_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_flag";
961 SELECT setval('"forum_badge_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_badge";
962 SELECT setval('"forum_award_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_award";
963 SELECT setval('"forum_openidnonce_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_openidnonce";
964 SELECT setval('"forum_openidassociation_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "forum_openidassociation";