 
     /* default action is set to INSTALLED only */
     action        integer       NOT NULL DEFAULT 1
-)
-;
+);
+
 CREATE TABLE canvas_templaterepository (
     id            integer       NOT NULL PRIMARY KEY  AUTO_INCREMENT,
     template_id   integer       NOT NULL REFERENCES canvas_template(id),

/* rebuild all tables from scratch */
DROP TABLE IF EXISTS canvas_user;
DROP TABLE IF EXISTS canvas_usermembership;
DROP TABLE IF EXISTS canvas_screenshot;
DROP TABLE IF EXISTS canvas_rating;
DROP TABLE IF EXISTS canvas_arch;
DROP TABLE IF EXISTS canvas_package_ratings;
DROP TABLE IF EXISTS canvas_package_screenshots;
DROP TABLE IF EXISTS canvas_package;
DROP TABLE IF EXISTS canvas_repository;
DROP TABLE IF EXISTS canvas_comment;
DROP TABLE IF EXISTS canvas_template_ratings;


CREATE TABLE canvas_package_ratings (
    id            integer       NOT NULL  PRIMARY KEY  AUTO_INCREMENT,
    package_id    integer       NOT NULL  REFERENCES canvas_package(id),
    rating_id     integer       NOT NULL  REFERENCES canvas_rating(id),
    tags          text,
    UNIQUE (package_id, rating_id)
);

CREATE TABLE canvas_package_screenshots (
    id            integer       NOT NULL  PRIMARY KEY  AUTO_INCREMENT,
    package_id    integer       NOT NULL  REFERENCES canvas_package(id),
    screenshot_id integer       NOT NULL  REFERENCES canvas_screenshot(id),
    tags          text,
    UNIQUE (package_id, screenshot_id)
);

