Skip to content

Commit d83bd91

Browse files
Merge pull request Civcraft#20 from TealNerd/master
Fixed db issues on startup
2 parents 1a97d9d + 95427ca commit d83bd91

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Bastion/src/isaac/bastion/Bastion.java

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ private void setupDatabase() {
7878
}
7979
storage = new BastionBlockStorage(db, getLogger());
8080
storage.registerMigrations();
81+
if(!db.updateDatabase()) {
82+
warning("Failed to update database, stopping bastion");
83+
getServer().getPluginManager().disablePlugin(this);
84+
return;
85+
}
8186
storage.loadBastions();
8287
}
8388

Bastion/src/isaac/bastion/storage/BastionBlockStorage.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ public void registerMigrations() {
6767
db.registerMigration(0, false,
6868
"create table if not exists `bastion_blocks`("
6969
+ "bastion_id int(10) unsigned NOT NULL AUTO_INCREMENT,"
70-
+ "bastion_type varchar(40) NOT NULL DEFAULT " + BastionType.getDefaultType()
70+
+ "bastion_type varchar(40) NOT NULL DEFAULT '" + BastionType.getDefaultType() + "',"
7171
+ "loc_x int(10),"
7272
+ "loc_y int(10),"
7373
+ "loc_z int(10),"
7474
+ "loc_world varchar(40) NOT NULL,"
7575
+ "placed bigint(20) Unsigned,"
7676
+ "fraction float(20) Unsigned,"
77-
+ "PRIMARY_KEY (`bastion_id`));");
77+
+ "PRIMARY KEY (`bastion_id`));");
7878
db.registerMigration(1, false,
79-
"ALTER TABLE bastion_blocks ADD COLUMN IF NOT EXISTS bastion_type VARCHAR(40) DEAULT '"
79+
"ALTER TABLE bastion_blocks ADD COLUMN IF NOT EXISTS bastion_type VARCHAR(40) DEFAULT '"
8080
+ BastionType.getDefaultType() + "';");
8181
db.registerMigration(2, false,
8282
"ALTER TABLE bastion_blocks ADD COLUMN dead TINYINT(1) DEFAULT 0;");

0 commit comments

Comments
 (0)