diff options
author | Sean Dague | 2008-06-11 21:01:33 +0000 |
---|---|---|
committer | Sean Dague | 2008-06-11 21:01:33 +0000 |
commit | 6c1fce61473b8d3faf9ee4602b9d0a392f148b7c (patch) | |
tree | 0cb0091493f725c0b06c2ceba493220eb85d507d /OpenSim/Data/SQLite | |
parent | updated resources for current sqlite schema for migrations (diff) | |
download | opensim-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')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteAssetData.cs | 24 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 120 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteRegionData.cs | 286 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserData.cs | 52 |
4 files changed, 269 insertions, 213 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 8d4fb99..4370cf7 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs | |||
@@ -64,7 +64,19 @@ namespace OpenSim.Data.SQLite | |||
64 | } | 64 | } |
65 | m_conn = new SqliteConnection(dbconnect); | 65 | m_conn = new SqliteConnection(dbconnect); |
66 | m_conn.Open(); | 66 | m_conn.Open(); |
67 | TestTables(m_conn); | 67 | |
68 | |||
69 | |||
70 | |||
71 | Assembly assem = GetType().Assembly; | ||
72 | Migration m = new Migration(m_conn, assem, "AssetStore"); | ||
73 | // TODO: remove this next line after changeset 6000, | ||
74 | // people should have all gotten into the migration swing | ||
75 | // again. | ||
76 | TestTables(m_conn, m); | ||
77 | |||
78 | m.Update(); | ||
79 | |||
68 | return; | 80 | return; |
69 | } | 81 | } |
70 | 82 | ||
@@ -258,7 +270,7 @@ namespace OpenSim.Data.SQLite | |||
258 | pcmd.ExecuteNonQuery(); | 270 | pcmd.ExecuteNonQuery(); |
259 | } | 271 | } |
260 | 272 | ||
261 | private static bool TestTables(SqliteConnection conn) | 273 | private static bool TestTables(SqliteConnection conn, Migration m) |
262 | { | 274 | { |
263 | SqliteCommand cmd = new SqliteCommand(assetSelect, conn); | 275 | SqliteCommand cmd = new SqliteCommand(assetSelect, conn); |
264 | SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); | 276 | SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); |
@@ -270,8 +282,14 @@ namespace OpenSim.Data.SQLite | |||
270 | catch (SqliteSyntaxException) | 282 | catch (SqliteSyntaxException) |
271 | { | 283 | { |
272 | m_log.Info("[ASSET DB]: SQLite Database doesn't exist... creating"); | 284 | m_log.Info("[ASSET DB]: SQLite Database doesn't exist... creating"); |
273 | InitDB(conn); | 285 | return false; |
274 | } | 286 | } |
287 | |||
288 | // if the tables are here, and we don't have a migration, | ||
289 | // set it to 1, as we're migrating off of legacy bits | ||
290 | if (m.Version == 0) | ||
291 | m.Version = 1; | ||
292 | |||
275 | return true; | 293 | return true; |
276 | } | 294 | } |
277 | 295 | ||
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs index 5acc5f2..5b77f82 100644 --- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs | |||
@@ -61,7 +61,12 @@ namespace OpenSim.Data.SQLite | |||
61 | 61 | ||
62 | conn.Open(); | 62 | conn.Open(); |
63 | 63 | ||
64 | TestTables(conn); | 64 | Assembly assem = GetType().Assembly; |
65 | Migration m = new Migration(conn, assem, "InventoryStore"); | ||
66 | // TODO: remove this line after changeset 6000 | ||
67 | TestTables(conn, m); | ||
68 | |||
69 | m.Update(); | ||
65 | 70 | ||
66 | SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); | 71 | SqliteCommand itemsSelectCmd = new SqliteCommand(invItemsSelect, conn); |
67 | invItemsDa = new SqliteDataAdapter(itemsSelectCmd); | 72 | invItemsDa = new SqliteDataAdapter(itemsSelectCmd); |
@@ -672,7 +677,7 @@ namespace OpenSim.Data.SQLite | |||
672 | scmd.ExecuteNonQuery(); | 677 | scmd.ExecuteNonQuery(); |
673 | } | 678 | } |
674 | 679 | ||
675 | private static bool TestTables(SqliteConnection conn) | 680 | private static bool TestTables(SqliteConnection conn, Migration m) |
676 | { | 681 | { |
677 | SqliteCommand invItemsSelectCmd = new SqliteCommand(invItemsSelect, conn); | 682 | SqliteCommand invItemsSelectCmd = new SqliteCommand(invItemsSelect, conn); |
678 | SqliteDataAdapter pDa = new SqliteDataAdapter(invItemsSelectCmd); | 683 | SqliteDataAdapter pDa = new SqliteDataAdapter(invItemsSelectCmd); |
@@ -688,63 +693,68 @@ namespace OpenSim.Data.SQLite | |||
688 | catch (SqliteSyntaxException) | 693 | catch (SqliteSyntaxException) |
689 | { | 694 | { |
690 | m_log.Info("[INVENTORY DB]: SQLite Database doesn't exist... creating"); | 695 | m_log.Info("[INVENTORY DB]: SQLite Database doesn't exist... creating"); |
691 | InitDB(conn); | 696 | return false; |
692 | } | 697 | } |
693 | 698 | ||
694 | pDa.Fill(tmpDS, "inventoryitems"); | 699 | if (m.Version == 0) |
695 | sDa.Fill(tmpDS, "inventoryfolders"); | 700 | m.Version = 1; |
696 | |||
697 | // Very clumsy way of checking whether we need to upgrade the database table version and then updating. Only | ||
698 | // putting up with this because this code should be blown away soon by nhibernate... | ||
699 | conn.Open(); | ||
700 | |||
701 | SqliteCommand cmd; | ||
702 | try | ||
703 | { | ||
704 | cmd = new SqliteCommand("select salePrice from inventoryitems limit 1;", conn); | ||
705 | cmd.ExecuteNonQuery(); | ||
706 | } | ||
707 | catch (SqliteSyntaxException) | ||
708 | { | ||
709 | m_log.Info("[INVENTORY DB]: Upgrading sqlite inventory database to version 2"); | ||
710 | |||
711 | cmd = new SqliteCommand("alter table inventoryitems add column salePrice integer default 99;", conn); | ||
712 | cmd.ExecuteNonQuery(); | ||
713 | cmd = new SqliteCommand("alter table inventoryitems add column saleType integer default 0;", conn); | ||
714 | cmd.ExecuteNonQuery(); | ||
715 | cmd = new SqliteCommand("alter table inventoryitems add column creationDate integer default 2000;", conn); | ||
716 | cmd.ExecuteNonQuery(); | ||
717 | cmd = new SqliteCommand("alter table inventoryitems add column groupID varchar(255) default '00000000-0000-0000-0000-000000000000';", conn); | ||
718 | cmd.ExecuteNonQuery(); | ||
719 | cmd = new SqliteCommand("alter table inventoryitems add column groupOwned integer default 0;", conn); | ||
720 | cmd.ExecuteNonQuery(); | ||
721 | cmd = new SqliteCommand("alter table inventoryitems add column flags integer default 0;", conn); | ||
722 | cmd.ExecuteNonQuery(); | ||
723 | 701 | ||
724 | pDa.Fill(tmpDS, "inventoryitems"); | ||
725 | } | ||
726 | finally | ||
727 | { | ||
728 | conn.Close(); | ||
729 | } | ||
730 | |||
731 | foreach (DataColumn col in createInventoryItemsTable().Columns) | ||
732 | { | ||
733 | if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName)) | ||
734 | { | ||
735 | m_log.Info("[INVENTORY DB]: Missing required column:" + col.ColumnName); | ||
736 | return false; | ||
737 | } | ||
738 | } | ||
739 | foreach (DataColumn col in createInventoryFoldersTable().Columns) | ||
740 | { | ||
741 | if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName)) | ||
742 | { | ||
743 | m_log.Info("[INVENTORY DB]: Missing required column:" + col.ColumnName); | ||
744 | return false; | ||
745 | } | ||
746 | } | ||
747 | return true; | 702 | return true; |
703 | |||
704 | // pDa.Fill(tmpDS, "inventoryitems"); | ||
705 | // sDa.Fill(tmpDS, "inventoryfolders"); | ||
706 | |||
707 | // // Very clumsy way of checking whether we need to upgrade the database table version and then updating. Only | ||
708 | // // putting up with this because this code should be blown away soon by nhibernate... | ||
709 | // conn.Open(); | ||
710 | |||
711 | // SqliteCommand cmd; | ||
712 | // try | ||
713 | // { | ||
714 | // cmd = new SqliteCommand("select salePrice from inventoryitems limit 1;", conn); | ||
715 | // cmd.ExecuteNonQuery(); | ||
716 | // } | ||
717 | // catch (SqliteSyntaxException) | ||
718 | // { | ||
719 | // m_log.Info("[INVENTORY DB]: Upgrading sqlite inventory database to version 2"); | ||
720 | |||
721 | // cmd = new SqliteCommand("alter table inventoryitems add column salePrice integer default 99;", conn); | ||
722 | // cmd.ExecuteNonQuery(); | ||
723 | // cmd = new SqliteCommand("alter table inventoryitems add column saleType integer default 0;", conn); | ||
724 | // cmd.ExecuteNonQuery(); | ||
725 | // cmd = new SqliteCommand("alter table inventoryitems add column creationDate integer default 2000;", conn); | ||
726 | // cmd.ExecuteNonQuery(); | ||
727 | // cmd = new SqliteCommand("alter table inventoryitems add column groupID varchar(255) default '00000000-0000-0000-0000-000000000000';", conn); | ||
728 | // cmd.ExecuteNonQuery(); | ||
729 | // cmd = new SqliteCommand("alter table inventoryitems add column groupOwned integer default 0;", conn); | ||
730 | // cmd.ExecuteNonQuery(); | ||
731 | // cmd = new SqliteCommand("alter table inventoryitems add column flags integer default 0;", conn); | ||
732 | // cmd.ExecuteNonQuery(); | ||
733 | |||
734 | // pDa.Fill(tmpDS, "inventoryitems"); | ||
735 | // } | ||
736 | // finally | ||
737 | // { | ||
738 | // conn.Close(); | ||
739 | // } | ||
740 | |||
741 | // foreach (DataColumn col in createInventoryItemsTable().Columns) | ||
742 | // { | ||
743 | // if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName)) | ||
744 | // { | ||
745 | // m_log.Info("[INVENTORY DB]: Missing required column:" + col.ColumnName); | ||
746 | // return false; | ||
747 | // } | ||
748 | // } | ||
749 | // foreach (DataColumn col in createInventoryFoldersTable().Columns) | ||
750 | // { | ||
751 | // if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName)) | ||
752 | // { | ||
753 | // m_log.Info("[INVENTORY DB]: Missing required column:" + col.ColumnName); | ||
754 | // return false; | ||
755 | // } | ||
756 | // } | ||
757 | // return true; | ||
748 | } | 758 | } |
749 | } | 759 | } |
750 | } | 760 | } |
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 | } |
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs index c9ef3c2..36ec9ea 100644 --- a/OpenSim/Data/SQLite/SQLiteUserData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserData.cs | |||
@@ -72,12 +72,20 @@ namespace OpenSim.Data.SQLite | |||
72 | connect = "URI=file:userprofiles.db,version=3"; | 72 | connect = "URI=file:userprofiles.db,version=3"; |
73 | 73 | ||
74 | SqliteConnection conn = new SqliteConnection(connect); | 74 | SqliteConnection conn = new SqliteConnection(connect); |
75 | TestTables(conn); | ||
76 | 75 | ||
77 | // This sucks, but It doesn't seem to work with the dataset Syncing :P | 76 | // This sucks, but It doesn't seem to work with the dataset Syncing :P |
78 | g_conn = conn; | 77 | g_conn = conn; |
79 | g_conn.Open(); | 78 | g_conn.Open(); |
80 | 79 | ||
80 | Assembly assem = GetType().Assembly; | ||
81 | Migration m = new Migration(g_conn, assem, "UserStore"); | ||
82 | |||
83 | // TODO: remove this after rev 6000 | ||
84 | TestTables(conn, m); | ||
85 | |||
86 | m.Update(); | ||
87 | |||
88 | |||
81 | ds = new DataSet(); | 89 | ds = new DataSet(); |
82 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); | 90 | da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); |
83 | daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn)); | 91 | daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn)); |
@@ -824,7 +832,7 @@ namespace OpenSim.Data.SQLite | |||
824 | conn.Close(); | 832 | conn.Close(); |
825 | } | 833 | } |
826 | 834 | ||
827 | private static bool TestTables(SqliteConnection conn) | 835 | private static bool TestTables(SqliteConnection conn, Migration m) |
828 | { | 836 | { |
829 | SqliteCommand cmd = new SqliteCommand(userSelect, conn); | 837 | SqliteCommand cmd = new SqliteCommand(userSelect, conn); |
830 | SqliteCommand fcmd = new SqliteCommand(userFriendsSelect, conn); | 838 | SqliteCommand fcmd = new SqliteCommand(userFriendsSelect, conn); |
@@ -842,26 +850,32 @@ namespace OpenSim.Data.SQLite | |||
842 | catch (SqliteSyntaxException) | 850 | catch (SqliteSyntaxException) |
843 | { | 851 | { |
844 | m_log.Info("[USER DB]: SQLite Database doesn't exist... creating"); | 852 | m_log.Info("[USER DB]: SQLite Database doesn't exist... creating"); |
845 | InitDB(conn); | 853 | return false; |
846 | } | ||
847 | conn.Open(); | ||
848 | try | ||
849 | { | ||
850 | cmd = new SqliteCommand("select webLoginKey from users limit 1;", conn); | ||
851 | cmd.ExecuteNonQuery(); | ||
852 | } | ||
853 | catch (SqliteSyntaxException) | ||
854 | { | ||
855 | cmd = new SqliteCommand("alter table users add column webLoginKey text default '00000000-0000-0000-0000-000000000000';", conn); | ||
856 | cmd.ExecuteNonQuery(); | ||
857 | pDa.Fill(tmpDS, "users"); | ||
858 | } | ||
859 | finally | ||
860 | { | ||
861 | conn.Close(); | ||
862 | } | 854 | } |
863 | 855 | ||
856 | if (m.Version == 0) | ||
857 | m.Version = 1; | ||
858 | |||
864 | return true; | 859 | return true; |
860 | |||
861 | // conn.Open(); | ||
862 | // try | ||
863 | // { | ||
864 | // cmd = new SqliteCommand("select webLoginKey from users limit 1;", conn); | ||
865 | // cmd.ExecuteNonQuery(); | ||
866 | // } | ||
867 | // catch (SqliteSyntaxException) | ||
868 | // { | ||
869 | // cmd = new SqliteCommand("alter table users add column webLoginKey text default '00000000-0000-0000-0000-000000000000';", conn); | ||
870 | // cmd.ExecuteNonQuery(); | ||
871 | // pDa.Fill(tmpDS, "users"); | ||
872 | // } | ||
873 | // finally | ||
874 | // { | ||
875 | // conn.Close(); | ||
876 | // } | ||
877 | |||
878 | // return true; | ||
865 | } | 879 | } |
866 | } | 880 | } |
867 | } | 881 | } |