 /* rebuild all tables from scratch */
 DROP TABLE IF EXISTS canvas_user;
 DROP TABLE IF EXISTS canvas_usermembership;
+DROP TABLE IF EXISTS canvas_arch;
+DROP TABLE IF EXISTS canvas_rating;
 DROP TABLE IF EXISTS canvas_screenshot;
-DROP TABLE IF EXISTS canvas_rating;
-DROP TABLE IF EXISTS canvas_arch;
+DROP TABLE IF EXISTS canvas_package;
+DROP TABLE IF EXISTS canvas_packagedetails;
 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;

    summary       text,
    license       varchar(256),
    url           varchar(256)
);

CREATE TABLE canvas_repository (


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)
);

