diff --git a/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java
new file mode 100644
index 00000000000..0eaa83a8cff
--- /dev/null
+++ b/server/src/com/cloud/upgrade/dao/UpgradeSnapshot217to223.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.cloud.upgrade.dao;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import com.cloud.utils.PropertiesUtil;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class UpgradeSnapshot217to223 implements DbUpgrade {
+
+ @Override
+ public File[] getPrepareScripts() {
+ File file = PropertiesUtil.findConfigFile("schema-snapshot-217to223.sql");
+ if (file == null) {
+ throw new CloudRuntimeException("Unable to find the upgrade script, chema-snapshot-217to223.sql");
+ }
+
+ return new File[] {file};
+ }
+
+ @Override
+ public void performDataMigration(Connection conn) {
+ }
+
+ @Override
+ public File[] getCleanupScripts() {
+ return null;
+ }
+
+ @Override
+ public String[] getUpgradableVersionRange() {
+ return new String[] { "2.1.7", "2.1.7" };
+ }
+
+ @Override
+ public String getUpgradedVersion() {
+ return "2.2.3";
+ }
+
+ @Override
+ public boolean supportsRollingUpgrade() {
+ return false;
+ }
+}
diff --git a/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java b/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java
index edae8c300bd..0e3d2e8aae4 100644
--- a/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java
+++ b/server/src/com/cloud/upgrade/dao/VersionDaoImpl.java
@@ -64,7 +64,7 @@ public class VersionDaoImpl extends GenericDaoBase implements V
protected VersionDaoImpl() {
super();
- _upgradeMap.put(new Pair("2.1.7", "2.2.1"), new DbUpgrade[] { new Upgrade217to22() });
+ _upgradeMap.put(new Pair("2.1.7", "2.2.3"), new DbUpgrade[] { new Upgrade217to22(), new Upgrade221to222(), new UpgradeSnapshot217to223()});
CurrentVersionSearch = createSearchBuilder(String.class);
CurrentVersionSearch.select(null, Func.FIRST, CurrentVersionSearch.entity().getVersion());
diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql
index a8eb824f502..815b8ba9db8 100755
--- a/setup/db/create-schema.sql
+++ b/setup/db/create-schema.sql
@@ -1258,13 +1258,6 @@ CREATE TABLE `cloud`.`snapshot_policy` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-CREATE TABLE `cloud`.`snapshot_policy_ref` (
- `snap_id` bigint unsigned NOT NULL,
- `volume_id` bigint unsigned NOT NULL,
- `policy_id` bigint unsigned NOT NULL,
- UNIQUE (snap_id, policy_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
CREATE TABLE `cloud`.`snapshot_schedule` (
`id` bigint unsigned NOT NULL auto_increment,
`volume_id` bigint unsigned NOT NULL COMMENT 'The volume for which this snapshot is being taken',
diff --git a/setup/db/schema-snapshot-217to223.sql b/setup/db/schema-snapshot-217to223.sql
new file mode 100644
index 00000000000..4255c131e83
--- /dev/null
+++ b/setup/db/schema-snapshot-217to223.sql
@@ -0,0 +1,11 @@
+ALTER table snapshots add column `data_center_id` bigint unsigned NOT NULL ;
+ALTER table snapshots add column `domain_id` bigint unsigned NOT NULL;
+ALTER table snapshots add column `disk_offering_id` bigint unsigned NOT NULL;
+ALTER table snapshots add column `size` bigint unsigned NOT NULL;
+ALTER table snapshots add column `version` varchar(32) DEFAULT '2.1';
+ALTER table snapshots add column `hypervisor_type` varchar(32) DEFAULT 'XenServer';
+
+UPDATE snapshots s, volumes v SET s.data_center_id=v.data_center_id, s.domain_id=v.domain_id, s.disk_offering_id=v.disk_offering_id, s.size=v.size WHERE s.volume_id = v.id
+UPDATE snapshots s, snapshot_policy sp, snapshot_policy_ref spr SET s.type=snapshot_type=sp.interval+3. WHERE s.id=spr.snap_id and spr.policy_id=sr.id
+
+DROP table snapshot_policy_ref