mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
[DS-2714] Oracle migration script for the service based api
This commit is contained in:
@@ -60,20 +60,17 @@ db.dialect=org.dspace.storage.rdbms.hibernate.postgres.DSpacePostgreSQL82Dialect
|
|||||||
db.url=jdbc:postgresql://localhost:5432/dspace
|
db.url=jdbc:postgresql://localhost:5432/dspace
|
||||||
db.username=dspace
|
db.username=dspace
|
||||||
db.password=dspace
|
db.password=dspace
|
||||||
|
db.schema = public
|
||||||
|
|
||||||
# oracle
|
# oracle
|
||||||
#db.driver= oracle.jdbc.OracleDriver
|
#db.driver= oracle.jdbc.OracleDriver
|
||||||
|
#db.dialect=org.hibernate.dialect.Oracle10gDialect
|
||||||
#db.url=jdbc:oracle:thin:@//localhost:1521/xe
|
#db.url=jdbc:oracle:thin:@//localhost:1521/xe
|
||||||
#db.username=dspace
|
#db.username=dspace
|
||||||
#db.password=dspace
|
#db.password=dspace
|
||||||
|
# The schema in oracle is the usually the user name
|
||||||
|
#db.schema = dspace
|
||||||
|
|
||||||
# Schema name - if your database contains multiple schemas, you can avoid
|
|
||||||
# problems with retrieving the definitions of duplicate object names by
|
|
||||||
# specifying the schema name that is used for DSpace.
|
|
||||||
# ORACLE USAGE NOTE: In Oracle, schema is equivalent to "username". This means
|
|
||||||
# specifying a "db.schema" is often unnecessary (i.e. you can leave it blank),
|
|
||||||
# UNLESS your Oracle DB Account (in db.username) has access to multiple schemas.
|
|
||||||
db.schema =
|
|
||||||
|
|
||||||
# Maximum number of DB connections in pool
|
# Maximum number of DB connections in pool
|
||||||
db.maxconnections = 30
|
db.maxconnections = 30
|
||||||
|
@@ -17,7 +17,7 @@ import java.util.Date;
|
|||||||
* Object representing an Item Request
|
* Object representing an Item Request
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="requestitem", schema = "public")
|
@Table(name="requestitem")
|
||||||
public class RequestItem {
|
public class RequestItem {
|
||||||
|
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ import java.util.Date;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="webapp", schema = "public")
|
@Table(name="webapp")
|
||||||
public class WebApp {
|
public class WebApp {
|
||||||
|
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ import java.util.Date;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="resourcepolicy", schema = "public")
|
@Table(name="resourcepolicy")
|
||||||
public class ResourcePolicy{
|
public class ResourcePolicy{
|
||||||
public static String TYPE_SUBMISSION = "TYPE_SUBMISSION";
|
public static String TYPE_SUBMISSION = "TYPE_SUBMISSION";
|
||||||
public static String TYPE_WORKFLOW = "TYPE_WORKFLOW";
|
public static String TYPE_WORKFLOW = "TYPE_WORKFLOW";
|
||||||
|
@@ -22,7 +22,7 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="checksum_history", schema = "public")
|
@Table(name="checksum_history")
|
||||||
public class ChecksumHistory
|
public class ChecksumHistory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ import javax.persistence.*;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="checksum_results", schema = "public")
|
@Table(name="checksum_results")
|
||||||
public final class ChecksumResult
|
public final class ChecksumResult
|
||||||
{
|
{
|
||||||
@Id
|
@Id
|
||||||
|
@@ -19,7 +19,7 @@ import java.util.Date;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="most_recent_checksum", schema = "public")
|
@Table(name="most_recent_checksum")
|
||||||
public class MostRecentChecksum implements Serializable
|
public class MostRecentChecksum implements Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="bitstream", schema = "public")
|
@Table(name="bitstream")
|
||||||
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
@Column(name="bitstream_id", insertable = false, updatable = false)
|
@Column(name="bitstream_id", insertable = false, updatable = false)
|
||||||
|
@@ -30,7 +30,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="bitstreamformatregistry", schema = "public")
|
@Table(name="bitstreamformatregistry")
|
||||||
public class BitstreamFormat
|
public class BitstreamFormat
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class BitstreamFormat
|
|||||||
private boolean internal = false;
|
private boolean internal = false;
|
||||||
|
|
||||||
@ElementCollection(fetch = FetchType.LAZY)
|
@ElementCollection(fetch = FetchType.LAZY)
|
||||||
@CollectionTable(name="fileextension", joinColumns=@JoinColumn(name="bitstream_format_id"), schema = "public")
|
@CollectionTable(name="fileextension", joinColumns=@JoinColumn(name="bitstream_format_id"))
|
||||||
@CollectionId(
|
@CollectionId(
|
||||||
columns = @Column(name="file_extension_id"),
|
columns = @Column(name="file_extension_id"),
|
||||||
type=@Type(type="integer"),
|
type=@Type(type="integer"),
|
||||||
|
@@ -30,7 +30,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="bundle", schema = "public")
|
@Table(name="bundle")
|
||||||
public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
@Column(name="bundle_id", insertable = false, updatable = false)
|
@Column(name="bundle_id", insertable = false, updatable = false)
|
||||||
@@ -46,7 +46,6 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "item2bundle",
|
name = "item2bundle",
|
||||||
joinColumns = {@JoinColumn(name = "bundle_id", referencedColumnName = "uuid") },
|
joinColumns = {@JoinColumn(name = "bundle_id", referencedColumnName = "uuid") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "uuid") }
|
inverseJoinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "uuid") }
|
||||||
|
@@ -18,7 +18,7 @@ import java.io.Serializable;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="bundle2bitstream", schema = "public")
|
@Table(name="bundle2bitstream")
|
||||||
public class BundleBitstream implements Serializable {
|
public class BundleBitstream implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -33,7 +33,7 @@ import java.util.List;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="collection", schema = "public")
|
@Table(name="collection")
|
||||||
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Collection extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -79,7 +79,6 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
|||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
|
@ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "community2collection",
|
name = "community2collection",
|
||||||
joinColumns = {@JoinColumn(name = "collection_id") },
|
joinColumns = {@JoinColumn(name = "collection_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "community_id") }
|
inverseJoinColumns = {@JoinColumn(name = "community_id") }
|
||||||
|
@@ -29,7 +29,7 @@ import java.util.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="community", schema = "public")
|
@Table(name="community")
|
||||||
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
/** log4j category */
|
/** log4j category */
|
||||||
@@ -40,7 +40,6 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "community2community",
|
name = "community2community",
|
||||||
joinColumns = {@JoinColumn(name = "parent_comm_id") },
|
joinColumns = {@JoinColumn(name = "parent_comm_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "child_comm_id") }
|
inverseJoinColumns = {@JoinColumn(name = "child_comm_id") }
|
||||||
|
@@ -21,7 +21,7 @@ import javax.persistence.*;
|
|||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Inheritance(strategy= InheritanceType.JOINED)
|
@Inheritance(strategy= InheritanceType.JOINED)
|
||||||
@Table(name = "dspaceobject", schema = "public")
|
@Table(name = "dspaceobject")
|
||||||
public abstract class DSpaceObject implements Serializable
|
public abstract class DSpaceObject implements Serializable
|
||||||
{
|
{
|
||||||
@Id
|
@Id
|
||||||
|
@@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="item", schema = "public")
|
@Table(name="item")
|
||||||
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +74,6 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
/** The bundles in this item - kept in sync with DB */
|
/** The bundles in this item - kept in sync with DB */
|
||||||
@ManyToMany(fetch = FetchType.LAZY, cascade={CascadeType.PERSIST})
|
@ManyToMany(fetch = FetchType.LAZY, cascade={CascadeType.PERSIST})
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "collection2item",
|
name = "collection2item",
|
||||||
joinColumns = {@JoinColumn(name = "item_id") },
|
joinColumns = {@JoinColumn(name = "item_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "collection_id") }
|
inverseJoinColumns = {@JoinColumn(name = "collection_id") }
|
||||||
|
@@ -22,7 +22,7 @@ import javax.persistence.*;
|
|||||||
* @see org.dspace.content.MetadataSchema
|
* @see org.dspace.content.MetadataSchema
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="metadatafieldregistry", schema = "public")
|
@Table(name="metadatafieldregistry")
|
||||||
public class MetadataField {
|
public class MetadataField {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -25,7 +25,7 @@ import javax.persistence.*;
|
|||||||
* @see org.dspace.content.MetadataField
|
* @see org.dspace.content.MetadataField
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="metadataschemaregistry", schema = "public")
|
@Table(name="metadataschemaregistry")
|
||||||
public class MetadataSchema
|
public class MetadataSchema
|
||||||
{
|
{
|
||||||
/** Short Name of built-in Dublin Core schema. */
|
/** Short Name of built-in Dublin Core schema. */
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
@@ -23,7 +24,7 @@ import javax.persistence.*;
|
|||||||
* @see org.dspace.content.MetadataField
|
* @see org.dspace.content.MetadataField
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="metadatavalue", schema = "public")
|
@Table(name="metadatavalue")
|
||||||
public class MetadataValue
|
public class MetadataValue
|
||||||
{
|
{
|
||||||
/** The reference to the metadata field */
|
/** The reference to the metadata field */
|
||||||
@@ -39,10 +40,9 @@ public class MetadataValue
|
|||||||
private MetadataField metadataField = null;
|
private MetadataField metadataField = null;
|
||||||
|
|
||||||
/** The value of the field */
|
/** The value of the field */
|
||||||
// @Column(name = "text_value")
|
@Lob
|
||||||
// @Lob
|
@Type(type="org.hibernate.type.MaterializedClobType")
|
||||||
// @Type(type = "org.hibernate.type.TextType")
|
@Column(name="text_value")
|
||||||
@Column(name="text_value", columnDefinition = "text")
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
/** The language of the field, may be <code>null</code> */
|
/** The language of the field, may be <code>null</code> */
|
||||||
|
@@ -18,7 +18,7 @@ import javax.persistence.Table;
|
|||||||
* By default, the handle suffix "0" represents the Site, e.g. "1721.1/0"
|
* By default, the handle suffix "0" represents the Site, e.g. "1721.1/0"
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "site", schema = "public")
|
@Table(name = "site")
|
||||||
public class Site extends DSpaceObject
|
public class Site extends DSpaceObject
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "workspaceitem", schema = "public")
|
@Table(name = "workspaceitem")
|
||||||
public class WorkspaceItem implements InProgressSubmission
|
public class WorkspaceItem implements InProgressSubmission
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "epersongroup2workspaceitem",
|
name = "epersongroup2workspaceitem",
|
||||||
joinColumns = {@JoinColumn(name = "workspace_item_id") },
|
joinColumns = {@JoinColumn(name = "workspace_item_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "eperson_group_id") }
|
inverseJoinColumns = {@JoinColumn(name = "eperson_group_id") }
|
||||||
|
@@ -71,7 +71,7 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
|||||||
String hqlQueryString = "SELECT item FROM Item as item join item.metadata metadatavalue WHERE item.inArchive=:in_archive AND metadatavalue.metadataField = :metadata_field";
|
String hqlQueryString = "SELECT item FROM Item as item join item.metadata metadatavalue WHERE item.inArchive=:in_archive AND metadatavalue.metadataField = :metadata_field";
|
||||||
if(value != null)
|
if(value != null)
|
||||||
{
|
{
|
||||||
hqlQueryString += " AND metadatavalue.value = :text_value";
|
hqlQueryString += " AND STR(metadatavalue.value) = :text_value";
|
||||||
}
|
}
|
||||||
Query query = createQuery(context, hqlQueryString);
|
Query query = createQuery(context, hqlQueryString);
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
if(StringUtils.isNotBlank(operator))
|
if(StringUtils.isNotBlank(operator))
|
||||||
{
|
{
|
||||||
query.append(" (");
|
query.append(" (");
|
||||||
query.append("lower(" + metadataField.toString()).append(".value) ").append(operator).append(" lower(:queryParam)");
|
query.append("lower(STR(" + metadataField.toString()).append(".value)) ").append(operator).append(" lower(:queryParam)");
|
||||||
query.append(")");
|
query.append(")");
|
||||||
if(i < metadataFields.size() - 1)
|
if(i < metadataFields.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -98,7 +98,7 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
query.append(" ORDER BY ");
|
query.append(" ORDER BY ");
|
||||||
for (int i = 0; i < metadataSortFields.size(); i++) {
|
for (int i = 0; i < metadataSortFields.size(); i++) {
|
||||||
MetadataField metadataField = metadataSortFields.get(i);
|
MetadataField metadataField = metadataSortFields.get(i);
|
||||||
query.append(metadataField.toString()).append(".value");
|
query.append("STR(").append(metadataField.toString()).append(".value)");
|
||||||
if(i != metadataSortFields.size() -1)
|
if(i != metadataSortFields.size() -1)
|
||||||
{
|
{
|
||||||
query.append(",");
|
query.append(",");
|
||||||
|
@@ -29,7 +29,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "eperson", schema = "public")
|
@Table(name = "eperson")
|
||||||
public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
@Column(name="eperson_id", insertable = false, updatable = false)
|
@Column(name="eperson_id", insertable = false, updatable = false)
|
||||||
|
@@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "epersongroup", schema = "public" )
|
@Table(name = "epersongroup" )
|
||||||
public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -48,7 +48,6 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
/** lists of epeople and groups in the group */
|
/** lists of epeople and groups in the group */
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "epersongroup2eperson",
|
name = "epersongroup2eperson",
|
||||||
joinColumns = {@JoinColumn(name = "eperson_group_id") },
|
joinColumns = {@JoinColumn(name = "eperson_group_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "eperson_id") }
|
inverseJoinColumns = {@JoinColumn(name = "eperson_id") }
|
||||||
@@ -57,7 +56,6 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
schema = "public",
|
|
||||||
name = "group2group",
|
name = "group2group",
|
||||||
joinColumns = {@JoinColumn(name = "parent_id") },
|
joinColumns = {@JoinColumn(name = "parent_id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "child_id") }
|
inverseJoinColumns = {@JoinColumn(name = "child_id") }
|
||||||
|
@@ -18,7 +18,7 @@ import java.io.Serializable;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "group2groupcache", schema = "public" )
|
@Table(name = "group2groupcache" )
|
||||||
public class Group2GroupCache implements Serializable {
|
public class Group2GroupCache implements Serializable {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -16,7 +16,7 @@ import java.util.Date;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="registrationdata", schema = "public")
|
@Table(name="registrationdata")
|
||||||
public class RegistrationData {
|
public class RegistrationData {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -17,7 +17,7 @@ import javax.persistence.*;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "subscription", schema = "public")
|
@Table(name = "subscription")
|
||||||
public class Subscription {
|
public class Subscription {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -17,7 +17,7 @@ import javax.persistence.*;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="handle", schema = "public")
|
@Table(name="handle")
|
||||||
public class Handle {
|
public class Handle {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -17,7 +17,7 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="harvested_collection", schema = "public")
|
@Table(name="harvested_collection")
|
||||||
public class HarvestedCollection
|
public class HarvestedCollection
|
||||||
{
|
{
|
||||||
@Id
|
@Id
|
||||||
|
@@ -17,7 +17,7 @@ import javax.persistence.*;
|
|||||||
* @author Alexey Maslov
|
* @author Alexey Maslov
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="harvested_item", schema = "public")
|
@Table(name="harvested_item")
|
||||||
public class HarvestedItem
|
public class HarvestedItem
|
||||||
{
|
{
|
||||||
@Id
|
@Id
|
||||||
|
@@ -18,7 +18,7 @@ import javax.persistence.*;
|
|||||||
* @author Pascal-Nicolas Becker
|
* @author Pascal-Nicolas Becker
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "Doi", schema = "public" )
|
@Table(name = "Doi" )
|
||||||
public class DOI
|
public class DOI
|
||||||
implements Identifier
|
implements Identifier
|
||||||
{
|
{
|
||||||
|
@@ -66,6 +66,7 @@ public class MigrationUtils
|
|||||||
constraintNameSQL = "SELECT CONSTRAINT_NAME " +
|
constraintNameSQL = "SELECT CONSTRAINT_NAME " +
|
||||||
"FROM USER_CONS_COLUMNS " +
|
"FROM USER_CONS_COLUMNS " +
|
||||||
"WHERE TABLE_NAME = ? AND COLUMN_NAME = ?";
|
"WHERE TABLE_NAME = ? AND COLUMN_NAME = ?";
|
||||||
|
cascade = true;
|
||||||
break;
|
break;
|
||||||
case "h2":
|
case "h2":
|
||||||
// In H2, constraints are listed in the "information_schema.constraints" table
|
// In H2, constraints are listed in the "information_schema.constraints" table
|
||||||
|
@@ -11,6 +11,10 @@ import org.hibernate.dialect.PostgreSQL82Dialect;
|
|||||||
import org.hibernate.metamodel.spi.TypeContributions;
|
import org.hibernate.metamodel.spi.TypeContributions;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.PostgresUUIDType;
|
import org.hibernate.type.PostgresUUIDType;
|
||||||
|
import org.hibernate.type.descriptor.sql.LongVarcharTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UUID's are not supported by default in hibernate due to differences in the database in order to fix this a custom sql dialect is needed.
|
* UUID's are not supported by default in hibernate due to differences in the database in order to fix this a custom sql dialect is needed.
|
||||||
@@ -38,4 +42,25 @@ public class DSpacePostgreSQL82Dialect extends PostgreSQL82Dialect
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override is needed to properly support the CLOB on metadatavalue in postgres & oracle.
|
||||||
|
* @param sqlCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
|
||||||
|
SqlTypeDescriptor descriptor;
|
||||||
|
switch (sqlCode) {
|
||||||
|
case Types.CLOB: {
|
||||||
|
descriptor = LongVarcharTypeDescriptor.INSTANCE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
descriptor = super.getSqlTypeDescriptorOverride(sqlCode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ import java.util.Date;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="versionitem", schema = "public")
|
@Table(name="versionitem")
|
||||||
public class Version {
|
public class Version {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
* @author Ben Bosman (ben at atmire dot com)
|
* @author Ben Bosman (ben at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="versionhistory", schema = "public")
|
@Table(name="versionhistory")
|
||||||
public class VersionHistory {
|
public class VersionHistory {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -23,7 +23,7 @@ import javax.persistence.*;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "workflowitem", schema = "public")
|
@Table(name = "workflowitem")
|
||||||
public class BasicWorkflowItem implements WorkflowItem
|
public class BasicWorkflowItem implements WorkflowItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ import javax.persistence.*;
|
|||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "tasklistitem", schema = "public")
|
@Table(name = "tasklistitem")
|
||||||
public class TaskListItem {
|
public class TaskListItem {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -20,7 +20,7 @@ import javax.persistence.*;
|
|||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_claimtask", schema = "public")
|
@Table(name="cwf_claimtask")
|
||||||
public class ClaimedTask {
|
public class ClaimedTask {
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ import java.sql.SQLException;
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_collectionrole", schema = "public")
|
@Table(name="cwf_collectionrole")
|
||||||
public class CollectionRole {
|
public class CollectionRole {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -20,7 +20,7 @@ import javax.persistence.*;
|
|||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_in_progress_user", schema = "public")
|
@Table(name="cwf_in_progress_user")
|
||||||
public class InProgressUser {
|
public class InProgressUser {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -22,7 +22,7 @@ import java.sql.SQLException;
|
|||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_pooltask", schema = "public")
|
@Table(name="cwf_pooltask")
|
||||||
public class PoolTask {
|
public class PoolTask {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -24,7 +24,7 @@ import java.sql.SQLException;
|
|||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_workflowitemrole", schema = "public")
|
@Table(name="cwf_workflowitemrole")
|
||||||
public class WorkflowItemRole {
|
public class WorkflowItemRole {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -24,7 +24,7 @@ import java.sql.SQLException;
|
|||||||
* @author Mark Diggory (markd at atmire dot com)
|
* @author Mark Diggory (markd at atmire dot com)
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="cwf_workflowitem", schema = "public")
|
@Table(name="cwf_workflowitem")
|
||||||
public class XmlWorkflowItem implements WorkflowItem {
|
public class XmlWorkflowItem implements WorkflowItem {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@@ -0,0 +1,356 @@
|
|||||||
|
DROP VIEW community2item;
|
||||||
|
|
||||||
|
CREATE TABLE dspaceobject
|
||||||
|
(
|
||||||
|
uuid RAW(16) NOT NULL PRIMARY KEY
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE site
|
||||||
|
(
|
||||||
|
uuid RAW(16) NOT NULL PRIMARY KEY REFERENCES dspaceobject(uuid)
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE eperson ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM eperson;
|
||||||
|
ALTER TABLE eperson ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE eperson MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE eperson ADD CONSTRAINT eperson_id_unique PRIMARY KEY (uuid);
|
||||||
|
UPDATE eperson SET require_certificate = '0' WHERE require_certificate IS NULL;
|
||||||
|
UPDATE eperson SET self_registered = '0' WHERE self_registered IS NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE epersongroup ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM epersongroup;
|
||||||
|
ALTER TABLE epersongroup ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE epersongroup MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE epersongroup ADD CONSTRAINT epersongroup_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
ALTER TABLE item ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM item;
|
||||||
|
ALTER TABLE item ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE item MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE item ADD CONSTRAINT item_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
ALTER TABLE community ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM community;
|
||||||
|
ALTER TABLE community ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE community MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE community ADD CONSTRAINT community_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE collection ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM collection;
|
||||||
|
ALTER TABLE collection ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE collection MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE collection ADD CONSTRAINT collection_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
ALTER TABLE bundle ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM bundle;
|
||||||
|
ALTER TABLE bundle ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE bundle MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE bundle ADD CONSTRAINT bundle_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
ALTER TABLE bitstream ADD uuid RAW(16) DEFAULT SYS_GUID();
|
||||||
|
INSERT INTO dspaceobject (uuid) SELECT uuid FROM bitstream;
|
||||||
|
ALTER TABLE bitstream ADD FOREIGN KEY (uuid) REFERENCES dspaceobject;
|
||||||
|
ALTER TABLE bitstream MODIFY uuid NOT NULL;
|
||||||
|
ALTER TABLE bitstream ADD CONSTRAINT bitstream_id_unique PRIMARY KEY (uuid);
|
||||||
|
|
||||||
|
-- Migrate EPersonGroup2EPerson table
|
||||||
|
ALTER TABLE EPersonGroup2EPerson RENAME COLUMN eperson_group_id to eperson_group_legacy_id;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson ADD eperson_group_id RAW(16) REFERENCES EpersonGroup(uuid);
|
||||||
|
ALTER TABLE EPersonGroup2EPerson ADD eperson_id RAW(16) REFERENCES Eperson(uuid);
|
||||||
|
UPDATE EPersonGroup2EPerson SET eperson_group_id = (SELECT EPersonGroup.uuid FROM EpersonGroup WHERE EPersonGroup2EPerson.eperson_group_legacy_id = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE EPersonGroup2EPerson SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE EPersonGroup2EPerson.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE EPersonGroup2EPerson MODIFY eperson_group_id NOT NULL;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson MODIFY eperson_id NOT NULL;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson DROP COLUMN eperson_group_legacy_id;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson DROP COLUMN eperson_legacy_id;
|
||||||
|
ALTER TABLE epersongroup2eperson DROP COLUMN id;
|
||||||
|
ALTER TABLE EPersonGroup2EPerson add CONSTRAINT EPersonGroup2EPerson_unique primary key (eperson_group_id,eperson_id);
|
||||||
|
|
||||||
|
-- Migrate GROUP2GROUP table
|
||||||
|
ALTER TABLE Group2Group RENAME COLUMN parent_id to parent_legacy_id;
|
||||||
|
ALTER TABLE Group2Group RENAME COLUMN child_id to child_legacy_id;
|
||||||
|
ALTER TABLE Group2Group ADD parent_id RAW(16) REFERENCES EpersonGroup(uuid);
|
||||||
|
ALTER TABLE Group2Group ADD child_id RAW(16) REFERENCES EpersonGroup(uuid);
|
||||||
|
UPDATE Group2Group SET parent_id = (SELECT EPersonGroup.uuid FROM EpersonGroup WHERE Group2Group.parent_legacy_id = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Group2Group SET child_id = (SELECT EpersonGroup.uuid FROM EpersonGroup WHERE Group2Group.child_legacy_id = EpersonGroup.eperson_group_id);
|
||||||
|
ALTER TABLE Group2Group MODIFY parent_id NOT NULL;
|
||||||
|
ALTER TABLE Group2Group MODIFY child_id NOT NULL;
|
||||||
|
ALTER TABLE Group2Group DROP COLUMN parent_legacy_id;
|
||||||
|
ALTER TABLE Group2Group DROP COLUMN child_legacy_id;
|
||||||
|
ALTER TABLE Group2Group DROP COLUMN id;
|
||||||
|
ALTER TABLE Group2Group add CONSTRAINT Group2Group_unique primary key (parent_id,child_id);
|
||||||
|
|
||||||
|
-- Migrate collection2item
|
||||||
|
ALTER TABLE Collection2Item RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE Collection2Item RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE Collection2Item ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
ALTER TABLE Collection2Item ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE Collection2Item SET collection_id = (SELECT Collection.uuid FROM Collection WHERE Collection2Item.collection_legacy_id = Collection.collection_id);
|
||||||
|
UPDATE Collection2Item SET item_id = (SELECT Item.uuid FROM Item WHERE Collection2Item.item_legacy_id = Item.item_id);
|
||||||
|
ALTER TABLE Collection2Item MODIFY collection_id NOT NULL;
|
||||||
|
ALTER TABLE Collection2Item MODIFY item_id NOT NULL;
|
||||||
|
ALTER TABLE Collection2Item DROP COLUMN collection_legacy_id;
|
||||||
|
ALTER TABLE Collection2Item DROP COLUMN item_legacy_id;
|
||||||
|
ALTER TABLE Collection2Item DROP COLUMN id;
|
||||||
|
-- Magic query that will delete all duplicate collection item_id references from the database (if we don't do this the primary key creation will fail)
|
||||||
|
DELETE FROM collection2item WHERE rowid NOT IN (SELECT MIN(rowid) FROM collection2item GROUP BY collection_id,item_id);
|
||||||
|
ALTER TABLE Collection2Item add CONSTRAINT collection2item_unique primary key (collection_id,item_id);
|
||||||
|
|
||||||
|
-- Migrate Community2Community
|
||||||
|
ALTER TABLE Community2Community RENAME COLUMN parent_comm_id to parent_legacy_id;
|
||||||
|
ALTER TABLE Community2Community RENAME COLUMN child_comm_id to child_legacy_id;
|
||||||
|
ALTER TABLE Community2Community ADD parent_comm_id RAW(16) REFERENCES Community(uuid);
|
||||||
|
ALTER TABLE Community2Community ADD child_comm_id RAW(16) REFERENCES Community(uuid);
|
||||||
|
UPDATE Community2Community SET parent_comm_id = (SELECT Community.uuid FROM Community WHERE Community2Community.parent_legacy_id = Community.community_id);
|
||||||
|
UPDATE Community2Community SET child_comm_id = (SELECT Community.uuid FROM Community WHERE Community2Community.child_legacy_id = Community.community_id);
|
||||||
|
ALTER TABLE Community2Community MODIFY parent_comm_id NOT NULL;
|
||||||
|
ALTER TABLE Community2Community MODIFY child_comm_id NOT NULL;
|
||||||
|
ALTER TABLE Community2Community DROP COLUMN parent_legacy_id;
|
||||||
|
ALTER TABLE Community2Community DROP COLUMN child_legacy_id;
|
||||||
|
ALTER TABLE Community2Community DROP COLUMN id;
|
||||||
|
ALTER TABLE Community2Community add CONSTRAINT Community2Community_unique primary key (parent_comm_id,child_comm_id);
|
||||||
|
|
||||||
|
-- Migrate community2collection
|
||||||
|
ALTER TABLE community2collection RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE community2collection RENAME COLUMN community_id to community_legacy_id;
|
||||||
|
ALTER TABLE community2collection ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
ALTER TABLE community2collection ADD community_id RAW(16) REFERENCES Community(uuid);
|
||||||
|
UPDATE community2collection SET collection_id = (SELECT Collection.uuid FROM Collection WHERE community2collection.collection_legacy_id = Collection.collection_id);
|
||||||
|
UPDATE community2collection SET community_id = (SELECT Community.uuid FROM Community WHERE community2collection.community_legacy_id = Community.community_id);
|
||||||
|
ALTER TABLE community2collection MODIFY collection_id NOT NULL;
|
||||||
|
ALTER TABLE community2collection MODIFY community_id NOT NULL;
|
||||||
|
ALTER TABLE community2collection DROP COLUMN collection_legacy_id;
|
||||||
|
ALTER TABLE community2collection DROP COLUMN community_legacy_id;
|
||||||
|
ALTER TABLE community2collection DROP COLUMN id;
|
||||||
|
ALTER TABLE community2collection add CONSTRAINT community2collection_unique primary key (collection_id,community_id);
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate Group2GroupCache table
|
||||||
|
ALTER TABLE Group2GroupCache RENAME COLUMN parent_id to parent_legacy_id;
|
||||||
|
ALTER TABLE Group2GroupCache RENAME COLUMN child_id to child_legacy_id;
|
||||||
|
ALTER TABLE Group2GroupCache ADD parent_id RAW(16) REFERENCES EpersonGroup(uuid);
|
||||||
|
ALTER TABLE Group2GroupCache ADD child_id RAW(16) REFERENCES EpersonGroup(uuid);
|
||||||
|
UPDATE Group2GroupCache SET parent_id = (SELECT EPersonGroup.uuid FROM EpersonGroup WHERE Group2GroupCache.parent_legacy_id = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Group2GroupCache SET child_id = (SELECT EpersonGroup.uuid FROM EpersonGroup WHERE Group2GroupCache.child_legacy_id = EpersonGroup.eperson_group_id);
|
||||||
|
ALTER TABLE Group2GroupCache MODIFY parent_id NOT NULL;
|
||||||
|
ALTER TABLE Group2GroupCache MODIFY child_id NOT NULL;
|
||||||
|
ALTER TABLE Group2GroupCache DROP COLUMN parent_legacy_id;
|
||||||
|
ALTER TABLE Group2GroupCache DROP COLUMN child_legacy_id;
|
||||||
|
ALTER TABLE Group2GroupCache DROP COLUMN id;
|
||||||
|
ALTER TABLE Group2GroupCache add CONSTRAINT Group2GroupCache_unique primary key (parent_id,child_id);
|
||||||
|
|
||||||
|
-- Migrate Item2Bundle
|
||||||
|
ALTER TABLE item2bundle RENAME COLUMN bundle_id to bundle_legacy_id;
|
||||||
|
ALTER TABLE item2bundle RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE item2bundle ADD bundle_id RAW(16) REFERENCES Bundle(uuid);
|
||||||
|
ALTER TABLE item2bundle ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE item2bundle SET bundle_id = (SELECT Bundle.uuid FROM Bundle WHERE item2bundle.bundle_legacy_id = Bundle.bundle_id);
|
||||||
|
UPDATE item2bundle SET item_id = (SELECT Item.uuid FROM Item WHERE item2bundle.item_legacy_id = Item.item_id);
|
||||||
|
ALTER TABLE item2bundle MODIFY bundle_id NOT NULL;
|
||||||
|
ALTER TABLE item2bundle MODIFY item_id NOT NULL;
|
||||||
|
ALTER TABLE item2bundle DROP COLUMN bundle_legacy_id;
|
||||||
|
ALTER TABLE item2bundle DROP COLUMN item_legacy_id;
|
||||||
|
ALTER TABLE item2bundle DROP COLUMN id;
|
||||||
|
ALTER TABLE item2bundle add CONSTRAINT item2bundle_unique primary key (bundle_id,item_id);
|
||||||
|
|
||||||
|
--Migrate Bundle2Bitsteam
|
||||||
|
ALTER TABLE bundle2bitstream RENAME COLUMN bundle_id to bundle_legacy_id;
|
||||||
|
ALTER TABLE bundle2bitstream RENAME COLUMN bitstream_id to bitstream_legacy_id;
|
||||||
|
ALTER TABLE bundle2bitstream ADD bundle_id RAW(16) REFERENCES Bundle(uuid);
|
||||||
|
ALTER TABLE bundle2bitstream ADD bitstream_id RAW(16) REFERENCES Bitstream(uuid);
|
||||||
|
UPDATE bundle2bitstream SET bundle_id = (SELECT bundle.uuid FROM bundle WHERE bundle2bitstream.bundle_legacy_id = bundle.bundle_id);
|
||||||
|
UPDATE bundle2bitstream SET bitstream_id = (SELECT bitstream.uuid FROM bitstream WHERE bundle2bitstream.bitstream_legacy_id = bitstream.bitstream_id);
|
||||||
|
ALTER TABLE bundle2bitstream MODIFY bundle_id NOT NULL;
|
||||||
|
ALTER TABLE bundle2bitstream MODIFY bitstream_id NOT NULL;
|
||||||
|
ALTER TABLE bundle2bitstream DROP COLUMN bundle_legacy_id;
|
||||||
|
ALTER TABLE bundle2bitstream DROP COLUMN bitstream_legacy_id;
|
||||||
|
ALTER TABLE bundle2bitstream DROP COLUMN id;
|
||||||
|
ALTER TABLE bundle2bitstream add CONSTRAINT bundle2bitstream_unique primary key (bitstream_id,bundle_id);
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate item
|
||||||
|
ALTER TABLE item RENAME COLUMN submitter_id to submitter_id_legacy_id;
|
||||||
|
ALTER TABLE item ADD submitter_id RAW(16) REFERENCES EPerson(uuid);
|
||||||
|
UPDATE item SET submitter_id = (SELECT eperson.uuid FROM eperson WHERE item.submitter_id_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE item DROP COLUMN submitter_id_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE item RENAME COLUMN owning_collection to owning_collection_legacy;
|
||||||
|
ALTER TABLE item ADD owning_collection RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE item SET owning_collection = (SELECT Collection.uuid FROM Collection WHERE item.owning_collection_legacy = collection.collection_id);
|
||||||
|
ALTER TABLE item DROP COLUMN owning_collection_legacy;
|
||||||
|
|
||||||
|
-- Migrate bundle
|
||||||
|
ALTER TABLE bundle RENAME COLUMN primary_bitstream_id to primary_bitstream_legacy_id;
|
||||||
|
ALTER TABLE bundle ADD primary_bitstream_id RAW(16) REFERENCES Bitstream(uuid);
|
||||||
|
UPDATE bundle SET primary_bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE bundle.primary_bitstream_legacy_id = Bitstream.bitstream_id);
|
||||||
|
ALTER TABLE bundle DROP COLUMN primary_bitstream_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate community references
|
||||||
|
ALTER TABLE Community RENAME COLUMN admin to admin_legacy;
|
||||||
|
ALTER TABLE Community ADD admin RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
UPDATE Community SET admin = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Community.admin_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
ALTER TABLE Community DROP COLUMN admin_legacy;
|
||||||
|
ALTER TABLE Community RENAME COLUMN logo_bitstream_id to logo_bitstream_legacy_id;
|
||||||
|
ALTER TABLE Community ADD logo_bitstream_id RAW(16) REFERENCES Bitstream(uuid);
|
||||||
|
UPDATE Community SET logo_bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE Community.logo_bitstream_legacy_id = Bitstream.bitstream_id);
|
||||||
|
ALTER TABLE Community DROP COLUMN logo_bitstream_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
--Migrate Collection references
|
||||||
|
ALTER TABLE Collection RENAME COLUMN workflow_step_1 to workflow_step_1_legacy;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN workflow_step_2 to workflow_step_2_legacy;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN workflow_step_3 to workflow_step_3_legacy;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN submitter to submitter_legacy;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN template_item_id to template_item_legacy_id;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN logo_bitstream_id to logo_bitstream_legacy_id;
|
||||||
|
ALTER TABLE Collection RENAME COLUMN admin to admin_legacy;
|
||||||
|
ALTER TABLE Collection ADD workflow_step_1 RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
ALTER TABLE Collection ADD workflow_step_2 RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
ALTER TABLE Collection ADD workflow_step_3 RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
ALTER TABLE Collection ADD submitter RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
ALTER TABLE Collection ADD template_item_id RAW(16);
|
||||||
|
ALTER TABLE Collection ADD logo_bitstream_id RAW(16);
|
||||||
|
ALTER TABLE Collection ADD admin RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
UPDATE Collection SET workflow_step_1 = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Collection.workflow_step_1_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Collection SET workflow_step_2 = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Collection.workflow_step_2_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Collection SET workflow_step_3 = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Collection.workflow_step_3_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Collection SET submitter = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Collection.submitter_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
UPDATE Collection SET template_item_id = (SELECT Item.uuid FROM Item WHERE Collection.template_item_legacy_id = Item.item_id);
|
||||||
|
UPDATE Collection SET logo_bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE Collection.logo_bitstream_legacy_id = Bitstream.bitstream_id);
|
||||||
|
UPDATE Collection SET admin = (SELECT EPersonGroup.uuid FROM EPersonGroup WHERE Collection.admin_legacy = EPersonGroup.eperson_group_id);
|
||||||
|
ALTER TABLE Collection DROP COLUMN workflow_step_1_legacy;
|
||||||
|
ALTER TABLE Collection DROP COLUMN workflow_step_2_legacy;
|
||||||
|
ALTER TABLE Collection DROP COLUMN workflow_step_3_legacy;
|
||||||
|
ALTER TABLE Collection DROP COLUMN submitter_legacy;
|
||||||
|
ALTER TABLE Collection DROP COLUMN template_item_legacy_id;
|
||||||
|
ALTER TABLE Collection DROP COLUMN logo_bitstream_legacy_id;
|
||||||
|
ALTER TABLE Collection DROP COLUMN admin_legacy;
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate resource policy references
|
||||||
|
ALTER TABLE ResourcePolicy RENAME COLUMN eperson_id to eperson_id_legacy_id;
|
||||||
|
ALTER TABLE ResourcePolicy ADD eperson_id RAW(16) REFERENCES EPerson(uuid);
|
||||||
|
UPDATE ResourcePolicy SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE ResourcePolicy.eperson_id_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE ResourcePolicy DROP COLUMN eperson_id_legacy_id;
|
||||||
|
ALTER TABLE ResourcePolicy RENAME COLUMN epersongroup_id to epersongroup_id_legacy_id;
|
||||||
|
ALTER TABLE ResourcePolicy ADD epersongroup_id RAW(16) REFERENCES EPersonGroup(uuid);
|
||||||
|
UPDATE ResourcePolicy SET epersongroup_id = (SELECT epersongroup.uuid FROM epersongroup WHERE ResourcePolicy.epersongroup_id_legacy_id = epersongroup.eperson_group_id);
|
||||||
|
ALTER TABLE ResourcePolicy DROP COLUMN epersongroup_id_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE ResourcePolicy ADD dspace_object RAW(16) REFERENCES dspaceobject(uuid);
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT eperson.uuid FROM eperson WHERE ResourcePolicy.resource_id = eperson.eperson_id AND ResourcePolicy.resource_type_id = 7) WHERE ResourcePolicy.resource_type_id = 7;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT epersongroup.uuid FROM epersongroup WHERE ResourcePolicy.resource_id = epersongroup.eperson_group_id AND ResourcePolicy.resource_type_id = 6) WHERE ResourcePolicy.resource_type_id = 6;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT community.uuid FROM community WHERE ResourcePolicy.resource_id = community.community_id AND ResourcePolicy.resource_type_id = 4) WHERE ResourcePolicy.resource_type_id = 4;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT collection.uuid FROM collection WHERE ResourcePolicy.resource_id = collection.collection_id AND ResourcePolicy.resource_type_id = 3) WHERE ResourcePolicy.resource_type_id = 3;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT item.uuid FROM item WHERE ResourcePolicy.resource_id = item.item_id AND ResourcePolicy.resource_type_id = 2) WHERE ResourcePolicy.resource_type_id = 2;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT bundle.uuid FROM bundle WHERE ResourcePolicy.resource_id = bundle.bundle_id AND ResourcePolicy.resource_type_id = 1) WHERE ResourcePolicy.resource_type_id = 1;
|
||||||
|
UPDATE ResourcePolicy SET dspace_object = (SELECT bitstream.uuid FROM bitstream WHERE ResourcePolicy.resource_id = bitstream.bitstream_id AND ResourcePolicy.resource_type_id = 0) WHERE ResourcePolicy.resource_type_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate Subscription
|
||||||
|
ALTER TABLE Subscription RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE Subscription ADD eperson_id RAW(16) REFERENCES EPerson(uuid);
|
||||||
|
UPDATE Subscription SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE Subscription.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE Subscription DROP COLUMN eperson_legacy_id;
|
||||||
|
ALTER TABLE Subscription RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE Subscription ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE Subscription SET collection_id = (SELECT collection.uuid FROM collection WHERE Subscription.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE Subscription DROP COLUMN collection_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
-- Migrate versionitem
|
||||||
|
ALTER TABLE versionitem RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE versionitem ADD eperson_id RAW(16) REFERENCES EPerson(uuid);
|
||||||
|
UPDATE versionitem SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE versionitem.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE versionitem DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE versionitem RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE versionitem ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE versionitem SET item_id = (SELECT item.uuid FROM item WHERE versionitem.item_legacy_id = item.item_id);
|
||||||
|
ALTER TABLE versionitem DROP COLUMN item_legacy_id;
|
||||||
|
|
||||||
|
-- Migrate handle table
|
||||||
|
ALTER TABLE handle RENAME COLUMN resource_id to resource_legacy_id;
|
||||||
|
ALTER TABLE handle ADD resource_id RAW(16) REFERENCES dspaceobject(uuid);
|
||||||
|
UPDATE handle SET resource_id = (SELECT community.uuid FROM community WHERE handle.resource_legacy_id = community.community_id AND handle.resource_type_id = 4);
|
||||||
|
UPDATE handle SET resource_id = (SELECT collection.uuid FROM collection WHERE handle.resource_legacy_id = collection.collection_id AND handle.resource_type_id = 3);
|
||||||
|
UPDATE handle SET resource_id = (SELECT item.uuid FROM item WHERE handle.resource_legacy_id = item.item_id AND handle.resource_type_id = 2);
|
||||||
|
|
||||||
|
-- Migrate metadata value table
|
||||||
|
DROP VIEW dcvalue;
|
||||||
|
|
||||||
|
ALTER TABLE metadatavalue ADD dspace_object_id RAW(16) REFERENCES dspaceobject(uuid);
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT eperson.uuid FROM eperson WHERE metadatavalue.resource_id = eperson.eperson_id AND metadatavalue.resource_type_id = 7) WHERE metadatavalue.resource_type_id= 7;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT epersongroup.uuid FROM epersongroup WHERE metadatavalue.resource_id = epersongroup.eperson_group_id AND metadatavalue.resource_type_id = 6) WHERE metadatavalue.resource_type_id= 6;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT community.uuid FROM community WHERE metadatavalue.resource_id = community.community_id AND metadatavalue.resource_type_id = 4) WHERE metadatavalue.resource_type_id= 4;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT collection.uuid FROM collection WHERE metadatavalue.resource_id = collection.collection_id AND metadatavalue.resource_type_id = 3) WHERE metadatavalue.resource_type_id= 3;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT item.uuid FROM item WHERE metadatavalue.resource_id = item.item_id AND metadatavalue.resource_type_id = 2) WHERE metadatavalue.resource_type_id= 2;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT bundle.uuid FROM bundle WHERE metadatavalue.resource_id = bundle.bundle_id AND metadatavalue.resource_type_id = 1) WHERE metadatavalue.resource_type_id= 1;
|
||||||
|
UPDATE metadatavalue SET dspace_object_id = (SELECT bitstream.uuid FROM bitstream WHERE metadatavalue.resource_id = bitstream.bitstream_id AND metadatavalue.resource_type_id = 0) WHERE metadatavalue.resource_type_id= 0;
|
||||||
|
DROP INDEX metadatavalue_item_idx;
|
||||||
|
DROP INDEX metadatavalue_item_idx2;
|
||||||
|
ALTER TABLE metadatavalue DROP COLUMN resource_id;
|
||||||
|
ALTER TABLE metadatavalue DROP COLUMN resource_type_id;
|
||||||
|
UPDATE MetadataValue SET confidence = -1 WHERE confidence IS NULL;
|
||||||
|
|
||||||
|
-- Alter harvested item
|
||||||
|
ALTER TABLE harvested_item RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE harvested_item ADD item_id RAW(16) REFERENCES item(uuid);
|
||||||
|
UPDATE harvested_item SET item_id = (SELECT item.uuid FROM item WHERE harvested_item.item_legacy_id = item.item_id);
|
||||||
|
ALTER TABLE harvested_item DROP COLUMN item_legacy_id;
|
||||||
|
|
||||||
|
-- Alter harvested collection
|
||||||
|
ALTER TABLE harvested_collection RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE harvested_collection ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE harvested_collection SET collection_id = (SELECT collection.uuid FROM collection WHERE harvested_collection.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE harvested_collection DROP COLUMN collection_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
--Alter workspaceitem
|
||||||
|
ALTER TABLE workspaceitem RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE workspaceitem ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE workspaceitem SET item_id = (SELECT item.uuid FROM item WHERE workspaceitem.item_legacy_id = item.item_id);
|
||||||
|
ALTER TABLE workspaceitem DROP COLUMN item_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE workspaceitem RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE workspaceitem ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE workspaceitem SET collection_id = (SELECT collection.uuid FROM collection WHERE workspaceitem.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE workspaceitem DROP COLUMN collection_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE epersongroup2workspaceitem RENAME COLUMN eperson_group_id to eperson_group_legacy_id;
|
||||||
|
ALTER TABLE epersongroup2workspaceitem ADD eperson_group_id RAW(16) REFERENCES epersongroup(uuid);
|
||||||
|
UPDATE epersongroup2workspaceitem SET eperson_group_id = (SELECT epersongroup.uuid FROM epersongroup WHERE epersongroup2workspaceitem.eperson_group_legacy_id = epersongroup.eperson_group_id);
|
||||||
|
ALTER TABLE epersongroup2workspaceitem DROP COLUMN eperson_group_legacy_id;
|
||||||
|
ALTER TABLE epersongroup2workspaceitem DROP COLUMN id;
|
||||||
|
ALTER TABLE epersongroup2workspaceitem MODIFY workspace_item_id NOT NULL;
|
||||||
|
ALTER TABLE epersongroup2workspaceitem MODIFY eperson_group_id NOT NULL;
|
||||||
|
ALTER TABLE epersongroup2workspaceitem add CONSTRAINT epersongroup2wsitem_unqiue primary key (workspace_item_id,eperson_group_id);
|
||||||
|
|
||||||
|
|
||||||
|
--Alter most_recent_checksum
|
||||||
|
ALTER TABLE most_recent_checksum RENAME COLUMN bitstream_id to bitstream_legacy_id;
|
||||||
|
ALTER TABLE most_recent_checksum ADD bitstream_id RAW(16) REFERENCES Bitstream(uuid);
|
||||||
|
UPDATE most_recent_checksum SET bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE most_recent_checksum.bitstream_legacy_id = Bitstream.bitstream_id);
|
||||||
|
ALTER TABLE most_recent_checksum DROP COLUMN bitstream_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE checksum_history RENAME COLUMN bitstream_id to bitstream_legacy_id;
|
||||||
|
ALTER TABLE checksum_history ADD bitstream_id RAW(16) REFERENCES Bitstream(uuid);
|
||||||
|
UPDATE checksum_history SET bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE checksum_history.bitstream_legacy_id = Bitstream.bitstream_id);
|
||||||
|
ALTER TABLE checksum_history DROP COLUMN bitstream_legacy_id;
|
||||||
|
RENAME checksum_history_seq TO checksum_history_check_id_seq;
|
||||||
|
|
||||||
|
--Alter table doi
|
||||||
|
ALTER TABLE doi ADD dspace_object RAW(16) REFERENCES dspaceobject(uuid);
|
||||||
|
UPDATE doi SET dspace_object = (SELECT community.uuid FROM community WHERE doi.resource_id = community.community_id AND doi.resource_type_id = 4) WHERE doi.resource_type_id = 4;
|
||||||
|
UPDATE doi SET dspace_object = (SELECT collection.uuid FROM collection WHERE doi.resource_id = collection.collection_id AND doi.resource_type_id = 3) WHERE doi.resource_type_id = 3;
|
||||||
|
UPDATE doi SET dspace_object = (SELECT item.uuid FROM item WHERE doi.resource_id = item.item_id AND doi.resource_type_id = 2) WHERE doi.resource_type_id = 2;
|
||||||
|
UPDATE doi SET dspace_object = (SELECT bundle.uuid FROM bundle WHERE doi.resource_id = bundle.bundle_id AND doi.resource_type_id = 1) WHERE doi.resource_type_id = 1;
|
||||||
|
UPDATE doi SET dspace_object = (SELECT bitstream.uuid FROM bitstream WHERE doi.resource_id = bitstream.bitstream_id AND doi.resource_type_id = 0) WHERE doi.resource_type_id = 0;
|
||||||
|
|
@@ -6,4 +6,25 @@
|
|||||||
-- http://www.dspace.org/license/
|
-- http://www.dspace.org/license/
|
||||||
--
|
--
|
||||||
|
|
||||||
-- TODO
|
-- Alter workflow item
|
||||||
|
ALTER TABLE workflowitem RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE workflowitem ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE workflowitem SET item_id = (SELECT item.uuid FROM item WHERE workflowitem.item_legacy_id = item.item_id);
|
||||||
|
ALTER TABLE workflowitem DROP COLUMN item_legacy_id;
|
||||||
|
|
||||||
|
-- Migrate task list item
|
||||||
|
ALTER TABLE TasklistItem RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE TasklistItem ADD eperson_id RAW(16) REFERENCES EPerson(uuid);
|
||||||
|
UPDATE TasklistItem SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE TasklistItem.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE TasklistItem DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
-- Migrate task workflow item
|
||||||
|
ALTER TABLE workflowitem RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE workflowitem ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE workflowitem SET collection_id = (SELECT collection.uuid FROM collection WHERE workflowitem.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE workflowitem DROP COLUMN collection_legacy_id;
|
||||||
|
ALTER TABLE workflowitem RENAME COLUMN owner to owner_legacy_id;
|
||||||
|
ALTER TABLE workflowitem ADD owner RAW(16) REFERENCES EPerson (uuid);
|
||||||
|
UPDATE workflowitem SET owner = (SELECT eperson.uuid FROM eperson WHERE workflowitem.owner_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE workflowitem DROP COLUMN owner_legacy_id;
|
||||||
|
|
||||||
|
@@ -6,4 +6,75 @@
|
|||||||
-- http://www.dspace.org/license/
|
-- http://www.dspace.org/license/
|
||||||
--
|
--
|
||||||
|
|
||||||
-- TODO
|
--
|
||||||
|
-- The contents of this file are subject to the license and copyright
|
||||||
|
-- detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
-- tree and available online at
|
||||||
|
--
|
||||||
|
-- http://www.dspace.org/license/
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
UPDATE collection SET workflow_step_1 = null;
|
||||||
|
UPDATE collection SET workflow_step_2 = null;
|
||||||
|
UPDATE collection SET workflow_step_3 = null;
|
||||||
|
|
||||||
|
-- cwf_workflowitem
|
||||||
|
|
||||||
|
ALTER TABLE cwf_workflowitem RENAME COLUMN item_id to item_legacy_id;
|
||||||
|
ALTER TABLE cwf_workflowitem ADD item_id RAW(16) REFERENCES Item(uuid);
|
||||||
|
UPDATE cwf_workflowitem SET item_id = (SELECT item.uuid FROM item WHERE cwf_workflowitem.item_legacy_id = item.item_id);
|
||||||
|
ALTER TABLE cwf_workflowitem DROP COLUMN item_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE cwf_workflowitem RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE cwf_workflowitem ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE cwf_workflowitem SET collection_id = (SELECT collection.uuid FROM collection WHERE cwf_workflowitem.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE cwf_workflowitem DROP COLUMN collection_legacy_id;
|
||||||
|
|
||||||
|
-- cwf_collectionrole
|
||||||
|
ALTER TABLE cwf_collectionrole RENAME COLUMN collection_id to collection_legacy_id;
|
||||||
|
ALTER TABLE cwf_collectionrole ADD collection_id RAW(16) REFERENCES Collection(uuid);
|
||||||
|
UPDATE cwf_collectionrole SET collection_id = (SELECT collection.uuid FROM collection WHERE cwf_collectionrole.collection_legacy_id = collection.collection_id);
|
||||||
|
ALTER TABLE cwf_collectionrole DROP COLUMN collection_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE cwf_collectionrole RENAME COLUMN group_id to group_legacy_id;
|
||||||
|
ALTER TABLE cwf_collectionrole ADD group_id RAW(16) REFERENCES epersongroup(uuid);
|
||||||
|
UPDATE cwf_collectionrole SET group_id = (SELECT epersongroup.uuid FROM epersongroup WHERE cwf_collectionrole.group_legacy_id = epersongroup.eperson_group_id);
|
||||||
|
ALTER TABLE cwf_collectionrole DROP COLUMN group_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
-- cwf_workflowitemrole
|
||||||
|
ALTER TABLE cwf_workflowitemrole RENAME COLUMN group_id to group_legacy_id;
|
||||||
|
ALTER TABLE cwf_workflowitemrole ADD group_id RAW(16) REFERENCES epersongroup(uuid);
|
||||||
|
UPDATE cwf_workflowitemrole SET group_id = (SELECT epersongroup.uuid FROM epersongroup WHERE cwf_workflowitemrole.group_legacy_id = epersongroup.eperson_group_id);
|
||||||
|
ALTER TABLE cwf_workflowitemrole DROP COLUMN group_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE cwf_workflowitemrole RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE cwf_workflowitemrole ADD eperson_id RAW(16) REFERENCES eperson(uuid);
|
||||||
|
UPDATE cwf_workflowitemrole SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE cwf_workflowitemrole.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE cwf_workflowitemrole DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
-- cwf_pooltask
|
||||||
|
ALTER TABLE cwf_pooltask RENAME COLUMN group_id to group_legacy_id;
|
||||||
|
ALTER TABLE cwf_pooltask ADD group_id RAW(16) REFERENCES epersongroup(uuid);
|
||||||
|
UPDATE cwf_pooltask SET group_id = (SELECT epersongroup.uuid FROM epersongroup WHERE cwf_pooltask.group_legacy_id = epersongroup.eperson_group_id);
|
||||||
|
ALTER TABLE cwf_pooltask DROP COLUMN group_legacy_id;
|
||||||
|
|
||||||
|
ALTER TABLE cwf_pooltask RENAME COLUMN eperson_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE cwf_pooltask ADD eperson_id RAW(16) REFERENCES eperson(uuid);
|
||||||
|
UPDATE cwf_pooltask SET eperson_id = (SELECT eperson.uuid FROM eperson WHERE cwf_pooltask.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE cwf_pooltask DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
-- cwf_claimtask
|
||||||
|
ALTER TABLE cwf_claimtask RENAME COLUMN owner_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE cwf_claimtask ADD owner_id RAW(16) REFERENCES eperson(uuid);
|
||||||
|
UPDATE cwf_claimtask SET owner_id = (SELECT eperson.uuid FROM eperson WHERE cwf_claimtask.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE cwf_claimtask DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
|
||||||
|
-- cwf_in_progress_user
|
||||||
|
ALTER TABLE cwf_in_progress_user RENAME COLUMN user_id to eperson_legacy_id;
|
||||||
|
ALTER TABLE cwf_in_progress_user ADD user_id RAW(16) REFERENCES eperson(uuid);
|
||||||
|
UPDATE cwf_in_progress_user SET user_id = (SELECT eperson.uuid FROM eperson WHERE cwf_in_progress_user.eperson_legacy_id = eperson.eperson_id);
|
||||||
|
ALTER TABLE cwf_in_progress_user DROP COLUMN eperson_legacy_id;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user