Project

General

Profile

Defect #6044 ยป fix_sequences.sql

sql code to update all the sequence counters to max(id)+1 - Marc Mengel, 2010-08-05 18:25

 
1
select setval('attachments_id_seq',(select max(id)+1 from attachments));
2
select setval('auth_sources_id_seq',(select max(id)+1 from auth_sources));
3
select setval('boards_id_seq',(select max(id)+1 from boards));
4
select setval('changes_id_seq',(select max(id)+1 from changes));
5
select setval('changesets_id_seq',(select max(id)+1 from changesets));
6
select setval('comments_id_seq',(select max(id)+1 from comments));
7
select setval('custom_fields_id_seq',(select max(id)+1 from custom_fields));
8
select setval('custom_values_id_seq',(select max(id)+1 from custom_values));
9
select setval('documents_id_seq',(select max(id)+1 from documents));
10
select setval('enabled_modules_id_seq',(select max(id)+1 from enabled_modules));
11
select setval('enumerations_id_seq',(select max(id)+1 from enumerations));
12
select setval('hudson_settings_id_seq',(select max(id)+1 from hudson_settings));
13
select setval('issue_categories_id_seq',(select max(id)+1 from issue_categories));
14
select setval('issue_relations_id_seq',(select max(id)+1 from issue_relations));
15
select setval('issue_statuses_id_seq',(select max(id)+1 from issue_statuses));
16
select setval('issues_id_seq',(select max(id)+1 from issues));
17
select setval('journal_details_id_seq',(select max(id)+1 from journal_details));
18
select setval('journals_id_seq',(select max(id)+1 from journals));
19
select setval('members_id_seq',(select max(id)+1 from members));
20
select setval('messages_id_seq',(select max(id)+1 from messages));
21
select setval('newissuealerts_id_seq',(select max(id)+1 from newissuealerts));
22
select setval('news_id_seq',(select max(id)+1 from news));
23
select setval('projects_id_seq',(select max(id)+1 from projects));
24
select setval('queries_id_seq',(select max(id)+1 from queries));
25
select setval('repositories_id_seq',(select max(id)+1 from repositories));
26
select setval('roles_id_seq',(select max(id)+1 from roles));
27
select setval('settings_id_seq',(select max(id)+1 from settings));
28
select setval('time_entries_id_seq',(select max(id)+1 from time_entries));
29
select setval('tokens_id_seq',(select max(id)+1 from tokens));
30
select setval('trackers_id_seq',(select max(id)+1 from trackers));
31
select setval('user_preferences_id_seq',(select max(id)+1 from user_preferences));
32
select setval('users_id_seq',(select max(id)+1 from users));
33
select setval('versions_id_seq',(select max(id)+1 from versions));
34
select setval('watchers_id_seq',(select max(id)+1 from watchers));
35
select setval('wiki_content_versions_id_seq',(select max(id)+1 from wiki_content_versions));
36
select setval('wiki_contents_id_seq',(select max(id)+1 from wiki_contents));
37
select setval('wiki_pages_id_seq',(select max(id)+1 from wiki_pages));
38
select setval('wiki_redirects_id_seq',(select max(id)+1 from wiki_redirects));
39
select setval('wikis_id_seq',(select max(id)+1 from wikis));
40
select setval('workflows_id_seq',(select max(id)+1 from workflows));
    (1-1/1)