/// <summary> /// Drops the entire schema. /// </summary> /// <param name="connection"></param> public static void Drop(NpgsqlConnection connection) { if (PostgreSQLSchemaTools.DetectRelationMembersTable(connection)) { PostgreSQLSchemaTools.DropRelationMembersTable(connection); } if (PostgreSQLSchemaTools.DetectRelationTagsTable(connection)) { PostgreSQLSchemaTools.DropRelationTagsTable(connection); } if (PostgreSQLSchemaTools.DetectRelationTable(connection)) { PostgreSQLSchemaTools.DropRelationTable(connection); } if (PostgreSQLSchemaTools.DetectWayNodesTable(connection)) { PostgreSQLSchemaTools.DropWayNodesTable(connection); } if (PostgreSQLSchemaTools.DetectWayTagsTable(connection)) { PostgreSQLSchemaTools.DropWayTagsTable(connection); } if (PostgreSQLSchemaTools.DetectWayTable(connection)) { PostgreSQLSchemaTools.DropWayTable(connection); } if (PostgreSQLSchemaTools.DetectNodeTagsTable(connection)) { PostgreSQLSchemaTools.DropNodeTagsTable(connection); } if (PostgreSQLSchemaTools.DetectNodeTable(connection)) { PostgreSQLSchemaTools.DropNodeTable(connection); } }
/// <summary> /// Creates a new/gets the existing connection. /// </summary> /// <returns></returns> private NpgsqlConnection CreateConnection() { if (_connection == null) { _connection = new NpgsqlConnection(_connectionString); _connection.Open(); if (_createAndDetectSchema) { // creates or detects the tables. PostgreSQLSchemaTools.CreateAndDetect(_connection); } } if (_connection.State != System.Data.ConnectionState.Open) { _connection.Open(); } return(_connection); }
/// <summary> /// Creates the entire schema but also detects existing tables. /// </summary> /// <param name="connection"></param> public static void CreateAndDetect(NpgsqlConnection connection) { if (!PostgreSQLSchemaTools.DetectNodeTable(connection)) { PostgreSQLSchemaTools.CreateNodeTable(connection); } if (!PostgreSQLSchemaTools.DetectNodeTagsTable(connection)) { PostgreSQLSchemaTools.CreateNodeTagsTable(connection); } if (!PostgreSQLSchemaTools.DetectWayTable(connection)) { PostgreSQLSchemaTools.CreateWayTable(connection); } if (!PostgreSQLSchemaTools.DetectWayTagsTable(connection)) { PostgreSQLSchemaTools.CreateWayTagsTable(connection); } if (!PostgreSQLSchemaTools.DetectWayNodesTable(connection)) { PostgreSQLSchemaTools.CreateWayNodesTable(connection); } if (!PostgreSQLSchemaTools.DetectRelationTable(connection)) { PostgreSQLSchemaTools.CreateRelationTable(connection); } if (!PostgreSQLSchemaTools.DetectRelationTagsTable(connection)) { PostgreSQLSchemaTools.CreateRelationTagsTable(connection); } if (!PostgreSQLSchemaTools.DetectRelationMembersTable(connection)) { PostgreSQLSchemaTools.CreateRelationMembersTable(connection); } }
/// <summary> /// Drops the relation tags table. /// </summary> /// <param name="connection"></param> public static void DropRelationTagsTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_RELATION_TAGS_DROP); }
/// <summary> /// Returns true if the relation tags table exists. /// </summary> /// <param name="connection"></param> /// <returns></returns> public static bool DetectRelationTagsTable(NpgsqlConnection connection) { return(PostgreSQLSchemaTools.DetectTable(connection, "relation_tags")); }
/// <summary> /// Creates the relation members table. /// </summary> /// <param name="connection"></param> /// <returns></returns> public static void CreateRelationMembersTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_RELATION_MEMBERS_CREATION); }
/// <summary> /// Drops the way tags table. /// </summary> /// <param name="connection"></param> public static void DropWayTagsTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_WAY_TAGS_DROP); }
/// <summary> /// Creates the way tags table. /// </summary> /// <param name="connection"></param> public static void CreateWayTagsTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_WAY_TAGS_CREATION); }
/// <summary> /// Returns true if the way nodes table exists. /// </summary> /// <param name="connection"></param> public static bool DetectWayNodesTable(NpgsqlConnection connection) { return(PostgreSQLSchemaTools.DetectTable(connection, "way_nodes")); }
/// <summary> /// Returns true if the node tags table exists. /// </summary> /// <param name="connection"></param> /// <returns></returns> public static bool DetectNodeTagsTable(NpgsqlConnection connection) { return(PostgreSQLSchemaTools.DetectTable(connection, "node_tags")); }
/// <summary> /// Drops the nodes table. /// </summary> /// <param name="connection"></param> public static void DropNodeTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_NODE_DROP); }
/// <summary> /// Creates the nodes table. /// </summary> /// <param name="connection"></param> /// <returns></returns> public static void CreateNodeTable(NpgsqlConnection connection) { PostgreSQLSchemaTools.ExecuteScript(connection, TABLE_NODE_CREATION); }