aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteRegionData.cs
diff options
context:
space:
mode:
authorSean Dague2008-06-11 21:01:33 +0000
committerSean Dague2008-06-11 21:01:33 +0000
commit6c1fce61473b8d3faf9ee4602b9d0a392f148b7c (patch)
tree0cb0091493f725c0b06c2ceba493220eb85d507d /OpenSim/Data/SQLite/SQLiteRegionData.cs
parentupdated resources for current sqlite schema for migrations (diff)
downloadopensim-SC_OLD-6c1fce61473b8d3faf9ee4602b9d0a392f148b7c.zip
opensim-SC_OLD-6c1fce61473b8d3faf9ee4602b9d0a392f148b7c.tar.gz
opensim-SC_OLD-6c1fce61473b8d3faf9ee4602b9d0a392f148b7c.tar.bz2
opensim-SC_OLD-6c1fce61473b8d3faf9ee4602b9d0a392f148b7c.tar.xz
check in working migration code fore SQLite. This
is now using migrations instead of the old model to create tables. Tested for existing old tables, and for creating new ones.
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteRegionData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs286
1 files changed, 150 insertions, 136 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 6a16a88..42299a0 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -84,6 +84,8 @@ namespace OpenSim.Data.SQLite
84 m_conn = new SqliteConnection(m_connectionString); 84 m_conn = new SqliteConnection(m_connectionString);
85 m_conn.Open(); 85 m_conn.Open();
86 86
87
88
87 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn); 89 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, m_conn);
88 primDa = new SqliteDataAdapter(primSelectCmd); 90 primDa = new SqliteDataAdapter(primSelectCmd);
89 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); 91 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
@@ -104,10 +106,15 @@ namespace OpenSim.Data.SQLite
104 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn); 106 SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, m_conn);
105 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd); 107 landAccessListDa = new SqliteDataAdapter(landAccessListSelectCmd);
106 108
107 // We fill the data set, now we've got copies in memory for the information 109 // This actually does the roll forward assembly stuff
108 // TODO: see if the linkage actually holds. 110 Assembly assem = GetType().Assembly;
109 // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); 111 Migration m = new Migration(m_conn, assem, "RegionStore");
110 TestTables(m_conn); 112
113 // TODO: After rev 6000, remove this. People should have
114 // been rolled onto the new migration code by then.
115 TestTables(m_conn, m);
116
117 m.Update();
111 118
112 lock (ds) 119 lock (ds)
113 { 120 {
@@ -1520,81 +1527,81 @@ namespace OpenSim.Data.SQLite
1520 /// Create the necessary database tables. 1527 /// Create the necessary database tables.
1521 /// </summary> 1528 /// </summary>
1522 /// <param name="conn"></param> 1529 /// <param name="conn"></param>
1523 private void InitDB(SqliteConnection conn) 1530 // private void InitDB(SqliteConnection conn)
1524 { 1531 // {
1525 string createPrims = defineTable(createPrimTable()); 1532 // string createPrims = defineTable(createPrimTable());
1526 string createShapes = defineTable(createShapeTable()); 1533 // string createShapes = defineTable(createShapeTable());
1527 string createItems = defineTable(createItemsTable()); 1534 // string createItems = defineTable(createItemsTable());
1528 string createTerrain = defineTable(createTerrainTable()); 1535 // string createTerrain = defineTable(createTerrainTable());
1529 string createLand = defineTable(createLandTable()); 1536 // string createLand = defineTable(createLandTable());
1530 string createLandAccessList = defineTable(createLandAccessListTable()); 1537 // string createLandAccessList = defineTable(createLandAccessListTable());
1531 1538
1532 SqliteCommand pcmd = new SqliteCommand(createPrims, conn); 1539 // SqliteCommand pcmd = new SqliteCommand(createPrims, conn);
1533 SqliteCommand scmd = new SqliteCommand(createShapes, conn); 1540 // SqliteCommand scmd = new SqliteCommand(createShapes, conn);
1534 SqliteCommand icmd = new SqliteCommand(createItems, conn); 1541 // SqliteCommand icmd = new SqliteCommand(createItems, conn);
1535 SqliteCommand tcmd = new SqliteCommand(createTerrain, conn); 1542 // SqliteCommand tcmd = new SqliteCommand(createTerrain, conn);
1536 SqliteCommand lcmd = new SqliteCommand(createLand, conn); 1543 // SqliteCommand lcmd = new SqliteCommand(createLand, conn);
1537 SqliteCommand lalcmd = new SqliteCommand(createLandAccessList, conn); 1544 // SqliteCommand lalcmd = new SqliteCommand(createLandAccessList, conn);
1538 1545
1539 try 1546 // try
1540 { 1547 // {
1541 pcmd.ExecuteNonQuery(); 1548 // pcmd.ExecuteNonQuery();
1542 } 1549 // }
1543 catch (SqliteSyntaxException) 1550 // catch (SqliteSyntaxException)
1544 { 1551 // {
1545 m_log.Warn("[REGION DB]: Primitives Table Already Exists"); 1552 // m_log.Warn("[REGION DB]: Primitives Table Already Exists");
1546 } 1553 // }
1547 1554
1548 try 1555 // try
1549 { 1556 // {
1550 scmd.ExecuteNonQuery(); 1557 // scmd.ExecuteNonQuery();
1551 } 1558 // }
1552 catch (SqliteSyntaxException) 1559 // catch (SqliteSyntaxException)
1553 { 1560 // {
1554 m_log.Warn("[REGION DB]: Shapes Table Already Exists"); 1561 // m_log.Warn("[REGION DB]: Shapes Table Already Exists");
1555 } 1562 // }
1556 1563
1557 if (persistPrimInventories) 1564 // if (persistPrimInventories)
1558 { 1565 // {
1559 try 1566 // try
1560 { 1567 // {
1561 icmd.ExecuteNonQuery(); 1568 // icmd.ExecuteNonQuery();
1562 } 1569 // }
1563 catch (SqliteSyntaxException) 1570 // catch (SqliteSyntaxException)
1564 { 1571 // {
1565 m_log.Warn("[REGION DB]: Primitives Inventory Table Already Exists"); 1572 // m_log.Warn("[REGION DB]: Primitives Inventory Table Already Exists");
1566 } 1573 // }
1567 } 1574 // }
1568 1575
1569 try 1576 // try
1570 { 1577 // {
1571 tcmd.ExecuteNonQuery(); 1578 // tcmd.ExecuteNonQuery();
1572 } 1579 // }
1573 catch (SqliteSyntaxException) 1580 // catch (SqliteSyntaxException)
1574 { 1581 // {
1575 m_log.Warn("[REGION DB]: Terrain Table Already Exists"); 1582 // m_log.Warn("[REGION DB]: Terrain Table Already Exists");
1576 } 1583 // }
1577 1584
1578 try 1585 // try
1579 { 1586 // {
1580 lcmd.ExecuteNonQuery(); 1587 // lcmd.ExecuteNonQuery();
1581 } 1588 // }
1582 catch (SqliteSyntaxException) 1589 // catch (SqliteSyntaxException)
1583 { 1590 // {
1584 m_log.Warn("[REGION DB]: Land Table Already Exists"); 1591 // m_log.Warn("[REGION DB]: Land Table Already Exists");
1585 } 1592 // }
1586 1593
1587 try 1594 // try
1588 { 1595 // {
1589 lalcmd.ExecuteNonQuery(); 1596 // lalcmd.ExecuteNonQuery();
1590 } 1597 // }
1591 catch (SqliteSyntaxException) 1598 // catch (SqliteSyntaxException)
1592 { 1599 // {
1593 m_log.Warn("[SQLITE]: LandAccessList Table Already Exists"); 1600 // m_log.Warn("[SQLITE]: LandAccessList Table Already Exists");
1594 } 1601 // }
1595 } 1602 // }
1596 1603
1597 private bool TestTables(SqliteConnection conn) 1604 private bool TestTables(SqliteConnection conn, Migration m)
1598 { 1605 {
1599 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); 1606 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
1600 SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); 1607 SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd);
@@ -1630,65 +1637,72 @@ namespace OpenSim.Data.SQLite
1630 catch (SqliteSyntaxException) 1637 catch (SqliteSyntaxException)
1631 { 1638 {
1632 m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating"); 1639 m_log.Info("[DATASTORE]: SQLite Database doesn't exist... creating");
1633 InitDB(conn); 1640 return false;
1634 }
1635
1636 pDa.Fill(tmpDS, "prims");
1637 sDa.Fill(tmpDS, "primshapes");
1638
1639 if (persistPrimInventories)
1640 iDa.Fill(tmpDS, "primitems");
1641
1642 tDa.Fill(tmpDS, "terrain");
1643 lDa.Fill(tmpDS, "land");
1644 lalDa.Fill(tmpDS, "landaccesslist");
1645
1646 foreach (DataColumn col in createPrimTable().Columns)
1647 {
1648 if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
1649 {
1650 m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1651 return false;
1652 }
1653 } 1641 }
1654 1642
1655 foreach (DataColumn col in createShapeTable().Columns) 1643 // if we've gotten this far, and our version is still 0,
1656 { 1644 // it's because the migration was never done, so
1657 if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) 1645 // initialize to 1 just to sync up to where we should be.
1658 { 1646
1659 m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName); 1647 if (m.Version == 0)
1660 return false; 1648 m.Version = 1;
1661 } 1649
1662 } 1650 // pDa.Fill(tmpDS, "prims");
1663 1651 // sDa.Fill(tmpDS, "primshapes");
1664 // XXX primitems should probably go here eventually 1652
1665 1653 // if (persistPrimInventories)
1666 foreach (DataColumn col in createTerrainTable().Columns) 1654 // iDa.Fill(tmpDS, "primitems");
1667 { 1655
1668 if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) 1656 // tDa.Fill(tmpDS, "terrain");
1669 { 1657 // lDa.Fill(tmpDS, "land");
1670 m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); 1658 // lalDa.Fill(tmpDS, "landaccesslist");
1671 return false; 1659
1672 } 1660 // foreach (DataColumn col in createPrimTable().Columns)
1673 } 1661 // {
1674 1662 // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
1675 foreach (DataColumn col in createLandTable().Columns) 1663 // {
1676 { 1664 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1677 if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) 1665 // return false;
1678 { 1666 // }
1679 m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName); 1667 // }
1680 return false; 1668
1681 } 1669 // foreach (DataColumn col in createShapeTable().Columns)
1682 } 1670 // {
1683 1671 // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
1684 foreach (DataColumn col in createLandAccessListTable().Columns) 1672 // {
1685 { 1673 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1686 if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) 1674 // return false;
1687 { 1675 // }
1688 m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName); 1676 // }
1689 return false; 1677
1690 } 1678 // // XXX primitems should probably go here eventually
1691 } 1679
1680 // foreach (DataColumn col in createTerrainTable().Columns)
1681 // {
1682 // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
1683 // {
1684 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1685 // return false;
1686 // }
1687 // }
1688
1689 // foreach (DataColumn col in createLandTable().Columns)
1690 // {
1691 // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
1692 // {
1693 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1694 // return false;
1695 // }
1696 // }
1697
1698 // foreach (DataColumn col in createLandAccessListTable().Columns)
1699 // {
1700 // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
1701 // {
1702 // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1703 // return false;
1704 // }
1705 // }
1692 1706
1693 return true; 1707 return true;
1694 } 1708 }