Преглед изворни кода

DB -> v3 for symbol->code assoc vs. ->codelet (fixes #13)

tags/v1.0^2
Ben Kurtovic пре 10 година
родитељ
комит
821a6ae4f1
2 измењених фајлова са 16 додато и 6 уклоњено
  1. +11
    -2
      bitshift/database/migration.py
  2. +5
    -4
      bitshift/database/schema.sql

+ 11
- 2
bitshift/database/migration.py Прегледај датотеку

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

VERSION = 2
VERSION = 3

MIGRATIONS = [
# 1 -> 2
@@ -17,12 +17,21 @@ MIGRATIONS = [
"""ALTER TABLE `codelets`
MODIFY COLUMN `codelet_code_id` BIGINT NOT NULL,
ADD KEY (`codelet_lang`),
ADD FOREIGN KEY (`codelet_code_id`)
ADD CONSTRAINT `codelets_ibfk_1` FOREIGN KEY (`codelet_code_id`)
REFERENCES `code` (`code_id`)
ON DELETE RESTRICT ON UPDATE CASCADE""",
"""ALTER TABLE `symbols`
ADD COLUMN `symbol_end_row` INT UNSIGNED NOT NULL,
ADD COLUMN `symbol_end_col` INT UNSIGNED NOT NULL"""
],
# 2 -> 3
[
"""ALTER TABLE `symbols`
DROP FOREIGN KEY `symbols_ibfk_1`,
CHANGE COLUMN `symbol_codelet` `symbol_code` BIGINT NOT NULL,
ADD CONSTRAINT `symbols_ibfk_1` FOREIGN KEY (`symbol_code`)
REFERENCES `code` (`code_id`)
ON DELETE CASCADE ON UPDATE CASCADE"""
]
]



+ 5
- 4
bitshift/database/schema.sql Прегледај датотеку

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

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 (2);
INSERT INTO `version` VALUES (3);

CREATE TABLE `origins` (
`origin_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -62,7 +62,7 @@ CREATE TABLE `authors` (

CREATE TABLE `symbols` (
`symbol_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`symbol_codelet` BIGINT UNSIGNED NOT NULL,
`symbol_code` BIGINT NOT NULL,
`symbol_type` TINYINT UNSIGNED NOT NULL,
`symbol_name` VARCHAR(512) NOT NULL,
`symbol_row` INT UNSIGNED NOT NULL,
@@ -71,8 +71,8 @@ CREATE TABLE `symbols` (
`symbol_end_col` INT UNSIGNED NOT NULL,
PRIMARY KEY (`symbol_id`),
KEY (`symbol_type`, `symbol_name`(32)),
FOREIGN KEY (`symbol_codelet`)
REFERENCES `codelets` (`codelet_id`)
FOREIGN KEY (`symbol_code`)
REFERENCES `code` (`code_id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;



Loading…
Откажи
Сачувај