⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jive_forums_oracle_8_upgrade_2_5_to_3_0.sql

📁 Jive Forums 论坛源码 v4.2.3
💻 SQL
📖 第 1 页 / 共 2 页
字号:
REM /////////////////////////////////////////////////////////////////
REM // $RCSfile$
REM // $Revision: 14794 $
REM // $Date: 2005-03-31 13:52:37 -0800 (Thu, 31 Mar 2005) $
REM /////////////////////////////////////////////////////////////////


REM /////////////////////////////////////////////////////////////////
REM //                                                             //
REM //    YOU MUST READ THIS SECTION BEFORE RUNNING THIS SCRIPT    //
REM //                                                             //
REM /////////////////////////////////////////////////////////////////


REM // There are 2 things you *must* do before running this script.
REM //
REM //  1) Back up your data. This is always a very safe thing to do
REM //     and a good idea in general. If errors occur upgrading
REM //     your data, you can always fall back.
REM //     A common Oracle utility for this is 'exp' - please
REM //     consult your Oracle DBA or read the Oracle documentation
REM //     for this.
REM //
REM //  2) Edit this script to be specific to your environment. See
REM //     the "DATABASE CONNECTION STRING" section below for full
REM //     instructions (approx. line 85 of this file).
REM //
REM //  Other notes:
REM //
REM //   1) Depending on the size of your data this script may require
REM //      a large rollback segment allocation. Please consult with
REM //      your DBA about this before doing this upgrade.
REM //   2) Consult with your DBA about the values of the LONG and
REM //      LONGCHUNKSIZE below. Most DB's should be able to handle
REM //      the default values.


REM // Set the LONG and LONGCHUNKSIZE parameters big enough so we
REM // can read in jiveMessage.body contents correctly:

SET LONG 1024000
SET LONGCHUNKSIZE 1024000
SET COPYCOMMIT 1000


REM // Upgrade the jiveMessage table

ALTER TABLE jiveMessage RENAME TO jiveMessage_temp;

CREATE TABLE jiveMessage (
  messageID         INTEGER NOT NULL,
  parentMessageID   INTEGER NULL,
  threadID          INTEGER NOT NULL,
  forumID           INTEGER NOT NULL,
  userID            INTEGER NULL,
  subject           VARCHAR2(255) NULL,
  body              LONG NULL,
  modValue          INTEGER NOT NULL,
  rewardPoints      INTEGER NOT NULL,
  creationDate      VARCHAR2(15) NOT NULL,
  modificationDate  VARCHAR2(15) NOT NULL,
  CONSTRAINT jiveMsg3_pk PRIMARY KEY (messageID)
);
CREATE INDEX jiveMsg3_forumID_idx ON jiveMessage (forumID ASC);
CREATE INDEX jiveMsg3_threadID_idx ON jiveMessage (threadID ASC);
CREATE INDEX jiveMsg3_userID_idx ON jiveMessage (userID ASC);
CREATE INDEX jiveMsg3_forumId_modVal_idx ON jiveMessage(forumID, modValue);
CREATE INDEX jiveMsg3_cDate_idx ON jiveMessage (creationDate ASC);
CREATE INDEX jiveMsg3_mDate_idx ON jiveMessage (modificationDate DESC);

REM // DATABASE CONNECTION STRING
REM //
REM // THE FOLLOWING TOKENS MUST BE REPLACED IN ORDER FOR THIS SCRIPT TO WORK
REM // CORRECTLY.
REM //
REM // TOKENS TO REPLACE: (REPLACE THE TOKEN AND THE BRACKET [] CHARACTERS)
REM //
REM // [USERNAME] = The user you use to connect to this schema, ie "scott".
REM // [PASSWORD] = The password for your user, ie "tiger"
REM // [SID]      = The database name (SID - service ID) for this database.
REM //
REM // After you replace the tokens, the "COPY" line should look something like:
REM //
REM // COPY FROM scott/tiger@ORCL -

COPY FROM [USERNAME]/[PASSWORD]@[SID] -
    INSERT jiveMessage (messageID, parentMessageID, threadID, forumID, userID, subject, body, -
                        modValue, rewardPoints, creationDate, modificationDate) -
    USING SELECT messageID, parentMessageID, threadID, forumID, userID, subject, body, -
                 modValue, rewardPoints, creationDate, modifiedDate -
          FROM jiveMessage_temp;

DROP TABLE jiveMessage_temp CASCADE CONSTRAINTS;

COMMIT;


REM // Create new Jive 3 tables

CREATE TABLE jiveUserReward (
  userID        INTEGER NOT NULL,
  rewardPoints  INTEGER NOT NULL,
  CONSTRAINT jiveUserReward_pk PRIMARY KEY (userID, rewardPoints)
);


CREATE TABLE jiveUserRoster (
  userID        INTEGER NOT NULL,
  subUserID     INTEGER NOT NULL,
  CONSTRAINT jiveUserRoster_pk PRIMARY KEY (userID, subUserID)
);


CREATE TABLE jiveReadTracker (
  userID            INTEGER NOT NULL,
  objectType        INTEGER NOT NULL,
  objectID          INTEGER NOT NULL,
  readDate          VARCHAR(15) NOT NULL,
  CONSTRAINT jiveReadTracker_pk PRIMARY KEY (userID, objectType, objectID)
);


REM // Rename 'modifiedDate' columns to 'modificationDate'. Do this via the following steps:
REM // 1) Rename the table name
REM // 2) Create the new table, use an embedded select statement from the old table to copy data.
REM // 3) Drop the old table

ALTER TABLE jiveForum RENAME TO jiveForum_temp;
CREATE TABLE jiveForum (
    forumID,
    name,
    description,
    modDefaultThreadVal,
    modMinThreadVal,
    modDefaultMsgVal,
    modMinMsgVal,
    creationDate,
    modificationDate,
    categoryID,
    categoryIndex
) AS SELECT forumID, name, description, modDefaultThreadVal, modMinThreadVal, modDefaultMsgVal,
            modMinMsgVal, creationDate, modifiedDate, categoryID, categoryIndex
     FROM jiveForum_temp;
DROP TABLE jiveForum_temp CASCADE CONSTRAINTS;
ALTER TABLE jiveForum ADD CONSTRAINT jiveForum_pk  PRIMARY KEY (forumID);
CREATE INDEX jiveForum_cat_idx ON jiveForum (categoryID);

COMMIT;

ALTER TABLE jiveThread RENAME TO jiveThread_temp;
CREATE TABLE jiveThread (
    threadID,
    forumID,
    rootMessageID,
    modValue,
    rewardPoints,
    creationDate,
    modificationDate
) AS SELECT threadID, forumID, rootMessageID, modValue, rewardPoints, creationDate, modifiedDate
     FROM jiveThread_temp;
DROP TABLE jiveThread_temp CASCADE CONSTRAINTS;
ALTER TABLE jiveThread ADD CONSTRAINT jiveThread_pk  PRIMARY KEY (threadID);
CREATE INDEX jiveThread_forumID_idx ON jiveThread (forumID ASC);
CREATE INDEX jiveThread_modValue_idx ON jiveThread (modValue ASC);
CREATE INDEX jiveThread_cDate_idx ON jiveThread (creationDate ASC);
CREATE INDEX jiveThread_mDate_idx ON jiveThread (modificationDate DESC);
CREATE INDEX jiveThread_fID_mV_idx ON jiveThread (forumID, modValue);

COMMIT;

ALTER TABLE jiveUser RENAME TO jiveUser_temp;
CREATE TABLE jiveUser (
    userID,
    username,
    passwordHash,
    name,
    nameVisible,
    email,
    emailVisible,
    creationDate,
    modificationDate
) AS SELECT userID, username, passwordHash, name, nameVisible, email, emailVisible,
            creationDate, modifiedDate
     FROM jiveUser_temp;

REM // Migrate the rewardPoint column out of the jiveUser table

INSERT INTO jiveUserReward (userID, rewardPoints)
    SELECT userID, rewardPoints FROM jiveUser_temp WHERE rewardPoints > 0;

REM // Drop the temporary table

DROP TABLE jiveUser_temp CASCADE CONSTRAINTS;

COMMIT;

REM // Create index on jiveUser

ALTER TABLE jiveUser ADD CONSTRAINT jiveUser_pk  PRIMARY KEY (userID);
CREATE INDEX jiveUser_cDate_idx on jiveUser (creationDate ASC);

COMMIT;

ALTER TABLE jiveGroup RENAME TO jiveGroup_temp;
CREATE TABLE jiveGroup (
    groupID,
    name,
    description,
    creationDate,
    modificationDate
) AS SELECT groupID, name, description, creationDate, modifiedDate
     FROM jiveGroup_temp;
DROP TABLE jiveGroup_temp CASCADE CONSTRAINTS;
ALTER TABLE jiveGroup ADD CONSTRAINT jiveGroup_pk PRIMARY KEY (groupID);
CREATE INDEX jiveGroup_cDate_idx on jiveGroup (creationDate ASC);

COMMIT;

ALTER TABLE jiveAttachment RENAME TO jiveAttachment_temp;
CREATE TABLE jiveAttachment (
    attachmentID,
    messageID,
    fileName,
    fileSize,
    contentType,
    creationDate,
    modificationDate
) AS SELECT attachmentID, messageID, fileName, fileSize, contentType, creationDate, modifiedDate
     FROM jiveAttachment_temp;
DROP TABLE jiveAttachment_temp CASCADE CONSTRAINTS;
ALTER TABLE jiveAttachment ADD CONSTRAINT jiveAttachment_pk PRIMARY KEY (attachmentID);
CREATE INDEX jiveAttachment_messageID_idx ON jiveAttachment (messageID);

COMMIT;

ALTER TABLE jiveCategory RENAME TO jiveCategory_temp;
CREATE TABLE jiveCategory (
    categoryID,
    name,
    description,
    creationDate,
    modificationDate,
    lft,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -