Browse Source

sql - remove old versions so you must start at v0.6

master
kanoi 10 years ago
parent
commit
a1ffb3656c
  1. 40
      sql/v0.1-v0.2.sql
  2. 115
      sql/v0.2-v0.3.sql
  3. 41
      sql/v0.3-v0.4.sql
  4. 42
      sql/v0.4-v0.5.sql
  5. 17
      sql/v0.6.txt

40
sql/v0.1-v0.2.sql

@ -1,40 +0,0 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='0.2' where vlock=1 and version='0.1';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "0.1" - found "%"', ver;
END $$;
ALTER TABLE ONLY poolstats
ADD COLUMN elapsed bigint DEFAULT 0 NOT NULL;
CREATE TABLE userstats (
poolinstance character varying(256) NOT NULL,
userid bigint NOT NULL,
elapsed bigint DEFAULT 0 NOT NULL,
hashrate float NOT NULL,
hashrate5m float NOT NULL,
hashrate1hr float NOT NULL,
hashrate24hr float NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
PRIMARY KEY (poolinstance, userid, createdate)
);
END transaction;

115
sql/v0.2-v0.3.sql

@ -1,115 +0,0 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='0.3' where vlock=1 and version='0.2';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "0.2" - found "%"', ver;
END $$;
DROP TABLE sharesummary;
CREATE TABLE sharesummary (
userid bigint NOT NULL,
workername character varying(256) NOT NULL,
workinfoid bigint NOT NULL,
diffacc float NOT NULL,
diffsta float NOT NULL,
diffdup float NOT NULL,
diffhi float NOT NULL,
diffrej float NOT NULL,
shareacc float NOT NULL,
sharesta float NOT NULL,
sharedup float NOT NULL,
sharehi float NOT NULL,
sharerej float NOT NULL,
sharecount bigint NOT NULL,
errorcount bigint NOT NULL,
firstshare timestamp with time zone NOT NULL,
lastshare timestamp with time zone NOT NULL,
complete char NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) NOT NULL,
createcode character varying(128) NOT NULL,
createinet character varying(128) NOT NULL,
modifydate timestamp with time zone NOT NULL,
modifyby character varying(64) NOT NULL,
modifycode character varying(128) NOT NULL,
modifyinet character varying(128) NOT NULL,
PRIMARY KEY (userid, workername, workinfoid)
);
DROP TABLE blocksummary;
CREATE TABLE workmarkers (
markerid bigint NOT NULL,
workinfoidend bigint NOT NULL,
workinfoidstart bigint NOT NULL,
description character varying(256) DEFAULT ''::character varying NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00',
PRIMARY KEY (workinfoidstart)
);
CREATE UNIQUE INDEX workmarkersid ON workmarkers USING btree (markerid);
CREATE TABLE markersummary (
markerid bigint NOT NULL,
userid bigint NOT NULL,
workername character varying(256) NOT NULL,
diffacc float NOT NULL,
diffsta float NOT NULL,
diffdup float NOT NULL,
diffhi float NOT NULL,
diffrej float NOT NULL,
shareacc float NOT NULL,
sharesta float NOT NULL,
sharedup float NOT NULL,
sharehi float NOT NULL,
sharerej float NOT NULL,
sharecount bigint NOT NULL,
errorcount bigint NOT NULL,
firstshare timestamp with time zone NOT NULL,
lastshare timestamp with time zone NOT NULL,
complete char NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) NOT NULL,
createcode character varying(128) NOT NULL,
createinet character varying(128) NOT NULL,
modifydate timestamp with time zone NOT NULL,
modifyby character varying(64) NOT NULL,
modifycode character varying(128) NOT NULL,
modifyinet character varying(128) NOT NULL,
PRIMARY KEY (markerid, userid, workername)
);
ALTER TABLE ONLY eventlog
ADD COLUMN poolinstance character varying(256) NOT NULL;
ALTER TABLE ONLY auths
ADD COLUMN poolinstance character varying(256) DEFAULT ''::character varying NOT NULL;
ALTER TABLE ONLY auths
ALTER COLUMN poolinstance DROP DEFAULT;
ALTER TABLE ONLY userstats
ADD COLUMN workername character varying(256) NOT NULL;
ALTER TABLE ONLY poolstats
ALTER COLUMN elapsed DROP DEFAULT;
END transaction;

41
sql/v0.3-v0.4.sql

@ -1,41 +0,0 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='0.4' where vlock=1 and version='0.3';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "0.3" - found "%"', ver;
END $$;
DROP TABLE userstats;
CREATE TABLE userstats (
userid bigint NOT NULL,
workername character varying(256) NOT NULL,
elapsed bigint NOT NULL,
hashrate float NOT NULL,
hashrate5m float NOT NULL,
hashrate1hr float NOT NULL,
hashrate24hr float NOT NULL,
summarylevel char NOT NULL,
statsdate timestamp with time zone NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
PRIMARY KEY (userid, workername, summarylevel, statsdate)
);
END transaction;

42
sql/v0.4-v0.5.sql

@ -1,42 +0,0 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='0.5' where vlock=1 and version='0.4';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "0.4" - found "%"', ver;
END $$;
DROP TABLE userstats;
CREATE TABLE userstats (
userid bigint NOT NULL,
workername character varying(256) NOT NULL,
elapsed bigint NOT NULL,
hashrate float NOT NULL,
hashrate5m float NOT NULL,
hashrate1hr float NOT NULL,
hashrate24hr float NOT NULL,
summarylevel char NOT NULL,
summarycount integer NOT NULL,
statsdate timestamp with time zone NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
PRIMARY KEY (userid, workername, summarylevel, statsdate)
);
END transaction;

17
sql/v0.6.txt

@ -1,17 +0,0 @@
To update to 0.6:
1) stop ckdb and ckpool
2) connect to postgres and delete the contents of all the tables except:
users, idcontrol, version
e.g. in psql to see all the table row counts: \i tables.sql
and to delete the rows from a table: delete from auths;
3) in pgsql: update version set version='0.6';
4) rename all your ckdb20140*.log files using the src/relog.sh script
5) start ckdb
6) wait for ckdb to say it is ready - i.e. wait for it to reload all the
ckdb20140*.log files
7) start ckpool
You can speed up step 6) if you don't care about losing the contents of the
DB forever: just go to the log directory and rename all the ckdb20140*.log
files something like: rename ".log" ".ignore" ckdb20140*.log
(or delete them)
Loading…
Cancel
Save