From 879fa4c926a0c01c1f2f877315203c587ded65a6 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 23 Feb 2013 15:33:09 -0300 Subject: [PATCH] Add postgres scripts. --- .../src/main/webapp/WEB-INF/app.properties | 11 +++ .../src/test/sql/postgres/create-database.sql | 3 + .../src/test/sql/postgres/create-schemas.sql | 78 +++++++++++++++++++ .../src/test/sql/postgres/drop-schemas.sql | 9 +++ 4 files changed, 101 insertions(+) create mode 100644 wise-webapp/src/test/sql/postgres/create-database.sql create mode 100644 wise-webapp/src/test/sql/postgres/create-schemas.sql create mode 100644 wise-webapp/src/test/sql/postgres/drop-schemas.sql diff --git a/wise-webapp/src/main/webapp/WEB-INF/app.properties b/wise-webapp/src/main/webapp/WEB-INF/app.properties index b631cbca..a9af7e54 100755 --- a/wise-webapp/src/main/webapp/WEB-INF/app.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/app.properties @@ -12,6 +12,17 @@ #database.validation.enabled=true #database.validation.query=SELECT 1 +## PostgreSQL configuration properties +#database.url=jdbc:postgresql:///wisemapping +#database.driver=org.postgresql.Driver +#database.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +#database.username= +#database.password= +#database.validation.enabled=true +#database.validation.query= +#database.validation.enabled=false + + # HSQL Configuration properties database.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping database.driver=org.hsqldb.jdbc.JDBCDriver diff --git a/wise-webapp/src/test/sql/postgres/create-database.sql b/wise-webapp/src/test/sql/postgres/create-database.sql new file mode 100644 index 00000000..7000f0e2 --- /dev/null +++ b/wise-webapp/src/test/sql/postgres/create-database.sql @@ -0,0 +1,3 @@ +CREATE DATABASE wisemapping; +CREATE USER wisemapping WITH PASSWORD 'password'; +GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping; diff --git a/wise-webapp/src/test/sql/postgres/create-schemas.sql b/wise-webapp/src/test/sql/postgres/create-schemas.sql new file mode 100644 index 00000000..df02023f --- /dev/null +++ b/wise-webapp/src/test/sql/postgres/create-schemas.sql @@ -0,0 +1,78 @@ +CREATE TABLE COLLABORATOR ( +id SERIAL NOT NULL PRIMARY KEY, +email varchar(255) NOT NULL UNIQUE, +creation_date date +); + +CREATE TABLE "user" ( +id SERIAL NOT NULL PRIMARY KEY, +colaborator_id INTEGER NOT NULL, +firstname varchar(255) NOT NULL, +lastname varchar(255) NOT NULL, +password varchar(255) NOT NULL, +activation_code BIGINT NOT NULL, +activation_date date, +allow_send_email text NOT NULL default 0, +locale varchar(5), +FOREIGN KEY(colaborator_id) REFERENCES COLLABORATOR(id) ON DELETE CASCADE ON UPDATE NO ACTION +) ; + + +CREATE TABLE MINDMAP ( +id SERIAL NOT NULL PRIMARY KEY, +title varchar(255) NOT NULL, +description varchar(255) NOT NULL, +xml bytea NOT NULL, +public BOOL not null default FALSE, +creation_date timestamp, +edition_date timestamp, +creator_id INTEGER not null, +tags varchar(1014) , +last_editor_id INTEGER NOT NULL --, +--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION +) ; + + +CREATE TABLE MINDMAP_HISTORY +(id SERIAL NOT NULL PRIMARY KEY, +xml bytea NOT NULL, +mindmap_id INTEGER NOT NULL, +creation_date timestamp, +editor_id INTEGER NOT NULL, +FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) ON DELETE CASCADE ON UPDATE NO ACTION +) ; + + +CREATE TABLE COLLABORATION_PROPERTIES( +id SERIAL NOT NULL PRIMARY KEY, +starred BOOL NOT NULL default FALSE, +mindmap_properties varchar(512) +); + +CREATE TABLE COLLABORATION ( +id SERIAL NOT NULL PRIMARY KEY, +colaborator_id INTEGER NOT NULL, +properties_id INTEGER NOT NULL, +mindmap_id INTEGER NOT NULL, +role_id INTEGER NOT NULL, +FOREIGN KEY(colaborator_id) REFERENCES COLLABORATOR(id), +FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) ON DELETE CASCADE ON UPDATE NO ACTION, +FOREIGN KEY(properties_id) REFERENCES COLLABORATION_PROPERTIES(id) ON DELETE CASCADE ON UPDATE NO ACTION +) ; + +CREATE TABLE TAG( +id SERIAL NOT NULL PRIMARY KEY, +name varchar(255) NOT NULL, +user_id INTEGER NOT NULL --, +--FOREIGN KEY(user_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION +) ; + + +CREATE TABLE ACCESS_AUDITORY ( +id SERIAL NOT NULL PRIMARY KEY, +login_date date, +user_id INTEGER NOT NULL +) ; + + +COMMIT; diff --git a/wise-webapp/src/test/sql/postgres/drop-schemas.sql b/wise-webapp/src/test/sql/postgres/drop-schemas.sql new file mode 100644 index 00000000..ea2ddf18 --- /dev/null +++ b/wise-webapp/src/test/sql/postgres/drop-schemas.sql @@ -0,0 +1,9 @@ +DROP TABLE TAG; +DROP TABLE ACCESS_AUDITORY; +DROP TABLE COLLABORATION; +DROP TABLE COLLABORATION_PROPERTIES; +DROP TABLE MINDMAP_HISTORY; +DROP TABLE MINDMAP; +DROP TABLE "user"; +DROP TABLE COLLABORATOR; +COMMIT; \ No newline at end of file