source: trunk/scripts/change-timestamp-oldrevisions @ 1184

Revision 1100, 1.4 KB checked in by bogdan2412, 2 years ago (diff)

Updated database dump

Updated db-strip script to remove user's remote ip information and also cleanup
entries previously left orphan in ia_user_round, ia_round_task and in
ia_*_tags. Also made it erase more useless stuff from the forum while keeping
more users, more jobs and more textblock history.

The total size of the dump is actually smaller now, even though it has more
relevant data.

Also fixed a bug in textblock_grep which caused the grep macro to stop working.

  • Property svn:executable set to *
Line 
1#! /usr/bin/env php
2
3<?php
4// This script changes timestamps for revisions so that
5// they won't share any common timestamp
6
7require_once(dirname($argv[0]) . "/utilities.php");
8
9db_connect();
10
11$res = db_query("SELECT name, timestamp from ia_textblock_revision " .
12                "ORDER BY name, timestamp");
13
14$prev_row = array("name" => "", "timestamp" => "");
15$prev_timestamp = 0;
16$count = 0;
17
18while ($row = db_next_row($res)) {
19    if ($row["name"] == $prev_row["name"] &&
20            db_date_parse($row["timestamp"]) <= $prev_timestamp) {
21
22        ++$prev_timestamp;
23        ++$count;
24
25        log_print(sprintf("Changed textblocks's %s timestamp from %s to %s",
26                    $row["name"], $row["timestamp"],
27                    db_date_format($prev_timestamp)));
28
29        db_query(sprintf("UPDATE ia_textblock_revision SET timestamp='%s' " .
30                "WHERE name=%s AND timestamp=%s LIMIT 1",
31                db_escape(db_date_format($prev_timestamp)),
32                db_quote($row["name"]), db_quote($row["timestamp"])));
33    } else {
34        $prev_timestamp = db_date_parse($row["timestamp"]);
35    }
36
37    $prev_row = $row;
38}
39
40log_print(sprintf("Changed %s entries", $count));
41
42db_query("ALTER TABLE `ia_textblock_revision`
43    ADD PRIMARY KEY  USING BTREE(`name`, `timestamp`),
44    DROP INDEX `should_be_primary`");
45log_print("Added PRIMARY KEY to `ia_textblock_revision`");
46
47?>
Note: See TracBrowser for help on using the repository browser.