Browse Source

empty_database procedure.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
fb341d5abd
2 changed files with 31 additions and 2 deletions
  1. +16
    -1
      bitshift/database/migration.py
  2. +15
    -1
      bitshift/database/schema.sql

+ 16
- 1
bitshift/database/migration.py View File

@@ -3,7 +3,7 @@ Contains information about database schema versions, and SQL queries to update
between them.
"""

VERSION = 8
VERSION = 9

MIGRATIONS = [
# 1 -> 2
@@ -100,6 +100,21 @@ MIGRATIONS = [
[
"""ALTER TABLE `origins`
DROP COLUMN `origin_image`"""
],
# 8 -> 9
[
"""DELIMITER //
CREATE PROCEDURE `empty_database`
BEGIN
DELETE FROM `codelets`;
DELETE FROM `code`;
DELETE FROM `cache`;
ALTER TABLE `codelets` AUTO_INCREMENT = 1;
ALTER TABLE `authors` AUTO_INCREMENT = 1;
ALTER TABLE `symbols` AUTO_INCREMENT = 1;
ALTER TABLE `symbol_locations` AUTO_INCREMENT = 1;
END
DELIMITER ;"""
]
]



+ 15
- 1
bitshift/database/schema.sql View File

@@ -1,4 +1,4 @@
-- Schema version 9

CREATE DATABASE `bitshift` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `bitshift`;
@@ -6,7 +6,7 @@ USE `bitshift`;
CREATE TABLE `version` (
`version` INT UNSIGNED NOT NULL
) ENGINE=InnoDB;
INSERT INTO `version` VALUES (8);
INSERT INTO `version` VALUES (9);

CREATE TABLE `origins` (
`origin_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -107,6 +107,19 @@ CREATE TABLE `cache_data` (
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DELIMITER //
CREATE PROCEDURE `empty_database`
BEGIN
DELETE FROM `codelets`;
DELETE FROM `code`;
DELETE FROM `cache`;
ALTER TABLE `codelets` AUTO_INCREMENT = 1;
ALTER TABLE `authors` AUTO_INCREMENT = 1;
ALTER TABLE `symbols` AUTO_INCREMENT = 1;
ALTER TABLE `symbol_locations` AUTO_INCREMENT = 1;
END
DELIMITER ;

CREATE EVENT `flush_cache`
ON SCHEDULE EVERY 1 HOUR
DO


Loading…
Cancel
Save