make sure all tables are innodb, for foreign keys to work
This commit is contained in:
		
							parent
							
								
									0df9672063
								
							
						
					
					
						commit
						97af29d7b6
					
				@ -57,6 +57,10 @@ class AdminPage implements Extension {
 | 
				
			|||||||
						$this->purge_unused_tags();
 | 
											$this->purge_unused_tags();
 | 
				
			||||||
						$redirect = true;
 | 
											$redirect = true;
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
 | 
										case 'convert to innodb':
 | 
				
			||||||
 | 
											$this->convert_to_innodb();
 | 
				
			||||||
 | 
											$redirect = true;
 | 
				
			||||||
 | 
											break;
 | 
				
			||||||
					case 'database dump':
 | 
										case 'database dump':
 | 
				
			||||||
						$this->dbdump($page);
 | 
											$this->dbdump($page);
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
@ -142,6 +146,17 @@ class AdminPage implements Extension {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private function convert_to_innodb() {
 | 
				
			||||||
 | 
							global $database;
 | 
				
			||||||
 | 
							if($database->engine->name == "mysql") {
 | 
				
			||||||
 | 
								$tables = $database->db->MetaTables();
 | 
				
			||||||
 | 
								foreach($tables as $table) {
 | 
				
			||||||
 | 
									log_info("upgrade", "converting $table to innodb");
 | 
				
			||||||
 | 
									$database->execute("ALTER TABLE $table TYPE=INNODB");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
add_event_listener(new AdminPage());
 | 
					add_event_listener(new AdminPage());
 | 
				
			||||||
?>
 | 
					?>
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,7 @@ class AdminPageTheme extends Themelet {
 | 
				
			|||||||
					<option value='recount tag use'>Recount tag use</option>
 | 
										<option value='recount tag use'>Recount tag use</option>
 | 
				
			||||||
					<option value='purge unused tags'>Purge unused tags</option>
 | 
										<option value='purge unused tags'>Purge unused tags</option>
 | 
				
			||||||
					<option value='database dump'>Download database contents</option>
 | 
										<option value='database dump'>Download database contents</option>
 | 
				
			||||||
 | 
										<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>
 | 
				
			||||||
				</select>
 | 
									</select>
 | 
				
			||||||
				<input type='submit' value='Go'>
 | 
									<input type='submit' value='Go'>
 | 
				
			||||||
			</form>
 | 
								</form>
 | 
				
			||||||
 | 
				
			|||||||
@ -18,9 +18,20 @@ class Upgrade implements Extension {
 | 
				
			|||||||
			// cry :S
 | 
								// cry :S
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if($config->get_int("db_version") < 6) { // 7
 | 
							if($config->get_int("db_version") < 7) {
 | 
				
			||||||
			// add column image->locked
 | 
								if($database->engine->name == "mysql") {
 | 
				
			||||||
 | 
									$tables = $database->db->MetaTables();
 | 
				
			||||||
 | 
									foreach($tables as $table) {
 | 
				
			||||||
 | 
										log_info("upgrade", "converting $table to innodb");
 | 
				
			||||||
 | 
										$database->execute("ALTER TABLE $table TYPE=INNODB");
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								$config->set_int("db_version", 7);
 | 
				
			||||||
 | 
								log_info("Database at version 7");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// TODO:
 | 
				
			||||||
 | 
							// add column image->locked
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
add_event_listener(new Upgrade(), 5);
 | 
					add_event_listener(new Upgrade(), 5);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user