Skip to content

Commit

Permalink
Merge pull request Civcraft#20 from TealNerd/master
Browse files Browse the repository at this point in the history
Fixed db issues on startup
  • Loading branch information
ProgrammerDan authored Oct 31, 2016
2 parents 1a97d9d + 95427ca commit d83bd91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Bastion/src/isaac/bastion/Bastion.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ private void setupDatabase() {
}
storage = new BastionBlockStorage(db, getLogger());
storage.registerMigrations();
if(!db.updateDatabase()) {
warning("Failed to update database, stopping bastion");
getServer().getPluginManager().disablePlugin(this);
return;
}
storage.loadBastions();
}

Expand Down
6 changes: 3 additions & 3 deletions Bastion/src/isaac/bastion/storage/BastionBlockStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ public void registerMigrations() {
db.registerMigration(0, false,
"create table if not exists `bastion_blocks`("
+ "bastion_id int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "bastion_type varchar(40) NOT NULL DEFAULT " + BastionType.getDefaultType()
+ "bastion_type varchar(40) NOT NULL DEFAULT '" + BastionType.getDefaultType() + "',"
+ "loc_x int(10),"
+ "loc_y int(10),"
+ "loc_z int(10),"
+ "loc_world varchar(40) NOT NULL,"
+ "placed bigint(20) Unsigned,"
+ "fraction float(20) Unsigned,"
+ "PRIMARY_KEY (`bastion_id`));");
+ "PRIMARY KEY (`bastion_id`));");
db.registerMigration(1, false,
"ALTER TABLE bastion_blocks ADD COLUMN IF NOT EXISTS bastion_type VARCHAR(40) DEAULT '"
"ALTER TABLE bastion_blocks ADD COLUMN IF NOT EXISTS bastion_type VARCHAR(40) DEFAULT '"
+ BastionType.getDefaultType() + "';");
db.registerMigration(2, false,
"ALTER TABLE bastion_blocks ADD COLUMN dead TINYINT(1) DEFAULT 0;");
Expand Down

0 comments on commit d83bd91

Please sign in to comment.