public void SeedDatabase() { // Create the database if it does not exist List <string> dbList = rethinkDB.DbList().Run <List <string> >(connection); if (dbList.Contains(this._dbName)) { rethinkDB.DbDrop(this._dbName).Run(connection); rethinkDB.DbCreate(this._dbName).Run(connection); } else if (!dbList.Contains(this._dbName)) { rethinkDB.DbCreate(this._dbName).Run(connection); } // Load the tables from the database List <string> tableList = rethinkDB.Db(this._dbName).TableList().Run <List <string> >(connection); List <string> createTables = new List <string>() { "Users", "UserSession", "SessionState", "PolicyHolders", "UserQuotation" }; // Create the tables if they do not exist foreach (var tableName in createTables) { // Check if the table exists in the database if (!tableList.Contains(tableName)) { rethinkDB.Db(this._dbName).TableCreate(tableName).Run(connection); } } }
protected void DropDb(string dbName) { var conn = _connectionFactory.CreateConnection(); var exists = R.DbList().Contains(db => db == dbName).Run(conn); if (exists) { R.DbDrop(dbName).Run(conn); } }
protected void DropDb(string dbName) { R.DbDrop(dbName).Run(conn); }