We are moving to Git Issues for bug tracking in future releases. During transition, content will be in both tools. If you'd like to file a new bug, please create an issue.

View | Details | Raw Unified | Return to bug 6097
Collapse All | Expand All

(-)a/dbscripts/xml/upgrade.xml (+5 lines)
 Lines 231-236    Link Here 
231
		<note file="docs/release-notes/README-2.3.4" />
231
		<note file="docs/release-notes/README-2.3.4" />
232
	</upgrade>
232
	</upgrade>
233
233
234
    <upgrade minversion="2.2.3.0" maxversion="2.3.2.0">
235
        <!-- COUNTER - counter_monthly_log update.-->
236
        <data file="plugins/generic/counter/counter_monthly_log_1_1.xml" />
237
    </upgrade>
238
234
	<!-- update plugin configuration - should be done as the final upgrade task -->
239
	<!-- update plugin configuration - should be done as the final upgrade task -->
235
	<code function="addPluginVersions" />
240
	<code function="addPluginVersions" />
236
</install>
241
</install>
(-)a/plugins/generic/counter/counter_monthly_log_1_1.xml (-4 / +20 lines)
 Lines 2-8    Link Here 
2
<!DOCTYPE data SYSTEM "../../../lib/pkp/dtd/xmlData.dtd">
2
<!DOCTYPE data SYSTEM "../../../lib/pkp/dtd/xmlData.dtd">
3
3
4
<!--
4
<!--
5
  * counter_monthly_log_1_7.xml
5
  * counter_monthly_log_1_1.xml
6
  *
6
  *
7
  * Copyright (c) 2003-2010 John Willinsky
7
  * Copyright (c) 2003-2010 John Willinsky
8
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 Lines 15-48    Link Here 
15
15
16
  <!-- rename current table to _old -->
16
  <!-- rename current table to _old -->
17
  <sql>
17
  <sql>
18
    <query driver="mysql">
18
    <query>
19
      ALTER TABLE counter_monthly_log RENAME TO counter_monthly_log_old
19
      ALTER TABLE counter_monthly_log RENAME TO counter_monthly_log_old
20
    </query>
20
    </query>
21
  </sql>
21
  </sql>
22
22
23
24
23
  <!-- create new counter_monthly_log with a new schema -->
25
  <!-- create new counter_monthly_log with a new schema -->
24
  <sql>
26
  <sql>
25
    <query driver="mysql">
27
    <query driver="mysql">
26
      CREATE TABLE counter_monthly_log ( year int(11) NOT NULL, month int(11) NOT NULL, journal_id int(11) NOT NULL, count_html int(20) NOT NULL DEFAULT 0, count_pdf int(20) NOT NULL DEFAULT 0, count_other int(20) NOT NULL DEFAULT 0, UNIQUE KEY counter_monthly_log_ukey (year,month,journal_id) )
28
      CREATE TABLE counter_monthly_log ( year int(11) NOT NULL, month int(11) NOT NULL, journal_id int(11) NOT NULL, count_html int(20) NOT NULL DEFAULT 0, count_pdf int(20) NOT NULL DEFAULT 0, count_other int(20) NOT NULL DEFAULT 0, UNIQUE KEY counter_monthly_log_ukey (year,month,journal_id) )
27
    </query>
29
    </query>
30
31
    <!-- Same thing for postgres, probably only works on PG 8.x -->
32
    <query driver="postgres7">
33
      CREATE TABLE counter_monthly_log ( year INT8 NOT NULL, journal_id INT8 NOT NULL, month INT8 NOT NULL, count_html INT8 DEFAULT 0 NOT NULL, count_pdf INT8 DEFAULT 0 NOT NULL, count_other INT8 DEFAULT 0 NOT NULL)
34
    </query>
35
    <query driver="postgres7">
36
      CREATE UNIQUE INDEX counter_monthly_log_key ON counter_monthly_log (year, month, journal_id)
37
    </query>
28
  </sql>
38
  </sql>
29
39
40
41
30
  <!-- pull data out of _old table and insert into new table, assume 0 for count_html, count_other -->
42
  <!-- pull data out of _old table and insert into new table, assume 0 for count_html, count_other -->
31
  <sql>
43
  <sql>
32
    <query driver="mysql">
44
    <query>
33
      INSERT INTO counter_monthly_log (year,month,journal_id,count_html,count_pdf,count_other) SELECT year, 1 as month, journal_id, 0, count_jan as count, 0 FROM counter_monthly_log_old UNION SELECT year, 2 as month, journal_id, 0, count_feb as count, 0 FROM counter_monthly_log_old UNION SELECT year, 3 as month, journal_id, 0, count_mar as count, 0 FROM counter_monthly_log_old UNION SELECT year, 4 as month, journal_id, 0, count_apr as count, 0 FROM counter_monthly_log_old UNION SELECT year, 5 as month, journal_id, 0, count_may as count, 0 FROM counter_monthly_log_old UNION SELECT year, 6 as month, journal_id, 0, count_jun as count, 0 FROM counter_monthly_log_old UNION SELECT year, 7 as month, journal_id, 0, count_jul as count, 0 FROM counter_monthly_log_old UNION SELECT year, 8 as month, journal_id, 0, count_aug as count, 0 FROM counter_monthly_log_old UNION SELECT year, 9 as month, journal_id, 0, count_sep as count, 0 FROM counter_monthly_log_old UNION SELECT year, 10 as month, journal_id, 0, count_oct as count, 0 FROM counter_monthly_log_old UNION SELECT year, 11 as month, journal_id, 0, count_nov as count, 0 FROM counter_monthly_log_old UNION SELECT year, 12 as month, journal_id, 0, count_dec as count, 0 FROM counter_monthly_log_old ORDER BY journal_id, year, month
45
      INSERT INTO counter_monthly_log (year,month,journal_id,count_html,count_pdf,count_other) SELECT year, 1 as month, journal_id, 0, count_jan as count, 0 FROM counter_monthly_log_old UNION SELECT year, 2 as month, journal_id, 0, count_feb as count, 0 FROM counter_monthly_log_old UNION SELECT year, 3 as month, journal_id, 0, count_mar as count, 0 FROM counter_monthly_log_old UNION SELECT year, 4 as month, journal_id, 0, count_apr as count, 0 FROM counter_monthly_log_old UNION SELECT year, 5 as month, journal_id, 0, count_may as count, 0 FROM counter_monthly_log_old UNION SELECT year, 6 as month, journal_id, 0, count_jun as count, 0 FROM counter_monthly_log_old UNION SELECT year, 7 as month, journal_id, 0, count_jul as count, 0 FROM counter_monthly_log_old UNION SELECT year, 8 as month, journal_id, 0, count_aug as count, 0 FROM counter_monthly_log_old UNION SELECT year, 9 as month, journal_id, 0, count_sep as count, 0 FROM counter_monthly_log_old UNION SELECT year, 10 as month, journal_id, 0, count_oct as count, 0 FROM counter_monthly_log_old UNION SELECT year, 11 as month, journal_id, 0, count_nov as count, 0 FROM counter_monthly_log_old UNION SELECT year, 12 as month, journal_id, 0, count_dec as count, 0 FROM counter_monthly_log_old ORDER BY journal_id, year, month
34
    </query>
46
    </query>
35
  </sql>
47
  </sql>
36
48
37
49
50
38
  <!-- remove the _old table -->
51
  <!-- remove the _old table -->
39
  <sql>
52
  <sql>
40
    <query driver="mysql">
53
    <query driver="mysql">
41
      DROP TABLE IF EXISTS counter_monthly_log_old
54
      DROP TABLE IF EXISTS counter_monthly_log_old
42
    </query>
55
    </query>
56
57
    <query driver="postgres7">
58
      DROP TABLE counter_monthly_log_old CASCADE
59
    </query>
43
  </sql>
60
  </sql>
44
61
45
  <!-- create indexes or primary key -->
46
62
47
63
48
</data>
64
</data>

Return to bug 6097