Skip to content

Commit

Permalink
Fix incorrect sql syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaar, Bjørn-Andre committed Dec 15, 2023
1 parent f6311e8 commit 865b131
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.hateoas.Links;
import org.springframework.hateoas.PagedModel;

import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAnyElement;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.Collection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import java.util.Collection;
import java.util.List;

import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAnyElement;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;

import org.springframework.core.ResolvableType;
import org.springframework.hateoas.Link;
Expand Down
5 changes: 2 additions & 3 deletions klass-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<woodstox-version>4.4.1</woodstox-version>
<commons-lang3-version>3.12.0</commons-lang3-version>
<rest-assured-version>2.9.0</rest-assured-version>
<apacheds-server-jndi-version>1.5.5</apacheds-server-jndi-version>
<apacheds-server-jndi-version>1.5.7</apacheds-server-jndi-version>
<asciidoctor-version>1.6.0</asciidoctor-version>
<maven-jaxb2-plugin-version>0.15.3</maven-jaxb2-plugin-version>
<tomcat7-maven-plugin-version>2.2</tomcat7-maven-plugin-version>
Expand Down Expand Up @@ -209,10 +209,9 @@
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>

</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.datatype.XMLGregorianCalendar;

import jakarta.persistence.EntityManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE correspondence_table DROP FOREIGN KEY fk_4tx0j45sopr6yj8wcedohj9w3;
ALTER TABLE correspondence_table DROP CONSTRAINT fk_4tx0j45sopr6yj8wcedohj9w3;
ALTER TABLE correspondence_table DROP COLUMN statistical_classification;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-- Migrating classifications from Stabas requires some increased column sizes
ALTER TABLE classification_item MODIFY official_name VARCHAR(2048);
ALTER TABLE classification_item ALTER COLUMN official_name VARCHAR(2048);
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
-- CorrespondenceTables stores level number instead of a foreign key to level
ALTER TABLE correspondence_table DROP FOREIGN KEY fk_cqdqwek3akelq2qqnhuydrkqr;
ALTER TABLE correspondence_table DROP FOREIGN KEY fk_8bn11tm1gsou84v8kmoug6qyt;
ALTER TABLE correspondence_table DROP CONSTRAINT fk_cqdqwek3akelq2qqnhuydrkqr;
ALTER TABLE correspondence_table DROP CONSTRAINT fk_8bn11tm1gsou84v8kmoug6qyt;

UPDATE correspondence_table ct SET ct.source_level_id =
COALESCE((SELECT l.level_number FROM level l WHERE l.id = ct.source_level_id), 0);

UPDATE correspondence_table ct SET ct.target_level_id =
COALESCE((SELECT l.level_number FROM level l WHERE l.id = ct.target_level_id), 0);

ALTER TABLE correspondence_table CHANGE source_level_id source_level_number BIGINT;
ALTER TABLE correspondence_table CHANGE target_level_id target_level_number BIGINT;
ALTER TABLE correspondence_table ALTER COLUMN source_level_id RENAME TO source_level_number;
ALTER TABLE correspondence_table ALTER COLUMN target_level_id RENAME TO target_level_number;

ALTER TABLE correspondence_table MODIFY source_level_number INTEGER NOT NULL;
ALTER TABLE correspondence_table MODIFY target_level_number INTEGER NOT NULL;
ALTER TABLE correspondence_table ALTER COLUMN source_level_number INTEGER NOT NULL;
ALTER TABLE correspondence_table ALTER COLUMN target_level_number INTEGER NOT NULL;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE user ADD email VARCHAR(255) NULL;
ALTER TABLE user ADD phone VARCHAR(255) NULL;
ALTER TABLE "user" ADD email VARCHAR(255) NULL;
ALTER TABLE "user" ADD phone VARCHAR(255) NULL;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ALTER TABLE subscription MODIFY verification VARCHAR(255) NOT NULL;
ALTER TABLE subscription ALTER COLUMN verification VARCHAR(255) NOT NULL;
12 changes: 6 additions & 6 deletions klass-shared/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ CREATE TABLE subscription
PRIMARY KEY (id)
);

CREATE TABLE user
CREATE TABLE "user"
(
id BIGINT NOT NULL auto_increment,
deleted BIT NOT NULL,
Expand Down Expand Up @@ -205,10 +205,10 @@ CREATE INDEX ct_target_idx ON correspondence_table (target_id);
ALTER TABLE subscriber
ADD CONSTRAINT subscriber_email_idx UNIQUE (email);

ALTER TABLE user
ALTER TABLE "user"
ADD CONSTRAINT user_username_idx UNIQUE (username);

CREATE INDEX user_fullname_idx ON user (fullname);
CREATE INDEX user_fullname_idx ON "user" (fullname);

ALTER TABLE user_favorites
ADD CONSTRAINT uk_dk8ngwbk9dgeuegrx1nuktdv1 UNIQUE (favorites_id);
Expand All @@ -231,7 +231,7 @@ ALTER TABLE classification_series

ALTER TABLE classification_series
ADD CONSTRAINT fk_jefvdo01kn4kq98m64ajli6y5 FOREIGN KEY (contact_person_id)
REFERENCES user (id);
REFERENCES "user" (id);

ALTER TABLE classification_series_statistical_units
ADD CONSTRAINT fk_rfx4t7rjg3hykfr39xi8dvrdu FOREIGN KEY (statistical_units_id)
Expand Down Expand Up @@ -283,7 +283,7 @@ ALTER TABLE statistical_classification

ALTER TABLE statistical_classification
ADD CONSTRAINT fk_12hsnu91tsf1c8b4697tv1bts FOREIGN KEY (contact_person_id)
REFERENCES user (id);
REFERENCES "user" (id);

ALTER TABLE statistical_classification
ADD CONSTRAINT fk_ie31cb245vkf1vhswws053s29 FOREIGN KEY (classification_id)
Expand Down Expand Up @@ -311,4 +311,4 @@ ALTER TABLE user_favorites

ALTER TABLE user_favorites
ADD CONSTRAINT fk_dx271ymxhckcafibaqijpda8h FOREIGN KEY (user_id) REFERENCES
user (id);
"user" (id);
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ALTER TABLE classification_series ADD hierarchy_last_modified DATETIME NULL;
UPDATE classification_series SET hierarchy_last_modified = last_modified;
ALTER TABLE classification_series MODIFY hierarchy_last_modified DATETIME NOT NULL;
ALTER TABLE classification_series ALTER COLUMN hierarchy_last_modified DATETIME NOT NULL;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- due to row limits of 65535 we need to reduce size for some fields to be able to increase name field
-- reduce
ALTER TABLE statistical_classification MODIFY valid_from VARCHAR(16);
ALTER TABLE statistical_classification MODIFY valid_to VARCHAR(16);
ALTER TABLE statistical_classification MODIFY uuid VARCHAR(64) NOT NULL;
ALTER TABLE statistical_classification ALTER COLUMN valid_from VARCHAR(16);
ALTER TABLE statistical_classification ALTER COLUMN valid_to VARCHAR(16);
ALTER TABLE statistical_classification ALTER COLUMN uuid VARCHAR(64) NOT NULL;

-- increase
ALTER TABLE statistical_classification MODIFY name VARCHAR(1000);
ALTER TABLE statistical_classification ALTER COLUMN name VARCHAR(1000);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE user_favorites
PRIMARY KEY (id)
);
ALTER TABLE user_favorites ADD CONSTRAINT fk_favorite_id FOREIGN KEY (favorites_id) REFERENCES classification_series (id);
ALTER TABLE user_favorites ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE user_favorites ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES "user" (id);
INSERT INTO user_favorites (user_id, favorites_id) SELECT
user_id,
favorites_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALTER TABLE correspondence_table MODIFY description TEXT NOT NULL;
ALTER TABLE classification_series MODIFY description TEXT NOT NULL;
ALTER TABLE statistical_classification MODIFY introduction TEXT NOT NULL;
ALTER TABLE correspondence_table ALTER COLUMN description TEXT NOT NULL;
ALTER TABLE classification_series ALTER COLUMN description TEXT NOT NULL;
ALTER TABLE statistical_classification ALTER COLUMN introduction TEXT NOT NULL;

Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
-- renames a foreign key column

ALTER TABLE level
DROP FOREIGN KEY fk_sxgu9ljubog3jnujn8fvohvn4;
DROP CONSTRAINT fk_sxgu9ljubog3jnujn8fvohvn4;

ALTER TABLE level CHANGE statistical_classification statistical_classification_id BIGINT not null;
ALTER TABLE level ALTER COLUMN statistical_classification RENAME TO statistical_classification_id;

ALTER TABLE level ALTER COLUMN statistical_classification_id BIGINT not null;

ALTER TABLE level
ADD CONSTRAINT fk_sxgu9ljubog3jnujn8fvohvn4 FOREIGN KEY (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
-- renames a foreign key column

ALTER TABLE correspondence_map
DROP FOREIGN KEY fk_74gwtjl4rjw3gw4x9idj4ux98;
DROP CONSTRAINT fk_74gwtjl4rjw3gw4x9idj4ux98;

ALTER TABLE correspondence_map CHANGE correspondence_table correspondence_table_id BIGINT not null;
ALTER TABLE correspondence_map ALTER COLUMN correspondence_table RENAME TO correspondence_table_id;

ALTER TABLE correspondence_map ALTER COLUMN correspondence_table_id BIGINT not null;

ALTER TABLE correspondence_map
ADD CONSTRAINT fk_74gwtjl4rjw3gw4x9idj4ux98 FOREIGN KEY (correspondence_table_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ ALTER TABLE level DROP COLUMN deleted;
ALTER TABLE statistical_unit DROP COLUMN deleted;
ALTER TABLE subscriber DROP COLUMN deleted;
ALTER TABLE subscription DROP COLUMN deleted;
ALTER TABLE user DROP COLUMN deleted;
ALTER TABLE "user" DROP COLUMN deleted;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- Removed not null constraint since a ReferencingClassificationItem does not have these set
ALTER TABLE classification_item MODIFY code VARCHAR(255);
ALTER TABLE classification_item MODIFY official_name VARCHAR(1024);
ALTER TABLE classification_item ALTER COLUMN code VARCHAR(255);
ALTER TABLE classification_item ALTER COLUMN official_name VARCHAR(1024);
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-- Migrating classifications from Stabas requires some increased column sizes
ALTER TABLE classification_item MODIFY notes VARCHAR(6000);
ALTER TABLE classification_item ALTER COLUMN notes VARCHAR(6000);

ALTER TABLE statistical_classification MODIFY introduction VARCHAR(7168) not null;
ALTER TABLE statistical_classification MODIFY legal_base VARCHAR(4000);
ALTER TABLE statistical_classification MODIFY publications VARCHAR(4000);
ALTER TABLE statistical_classification MODIFY derived_from VARCHAR(4000);
ALTER TABLE statistical_classification ALTER COLUMN introduction VARCHAR(7168) not null;
ALTER TABLE statistical_classification ALTER COLUMN legal_base VARCHAR(4000);
ALTER TABLE statistical_classification ALTER COLUMN publications VARCHAR(4000);
ALTER TABLE statistical_classification ALTER COLUMN derived_from VARCHAR(4000);

ALTER TABLE correspondence_table MODIFY description VARCHAR(4000) not null;
ALTER TABLE correspondence_table ALTER COLUMN description VARCHAR(4000) not null;

ALTER TABLE level MODIFY name VARCHAR(1000) not null;
ALTER TABLE level ALTER COLUMN name VARCHAR(1000) not null;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;
import javax.xml.datatype.XMLGregorianCalendar;

import org.slf4j.Logger;
Expand Down
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@
<asciidoctor-version>2.2.4</asciidoctor-version>
<maven-jaxb2-plugin-version>0.15.3</maven-jaxb2-plugin-version>
<tomcat7-maven-plugin-version>2.2</tomcat7-maven-plugin-version>

<!--IMPORTANT HIBERNATE BUG FIX ( needed for Translatable as lobs)-->
<!--https://hibernate.atlassian.net/browse/HHH-10818-->


<!-- Override Spring Boot managed version. Flyway bug #995 forces us to use version 4.0 or newer.
Replacing old search engine with solr search
Remove when Spring Boot includes this version or newer -->
<flyway.version>4.1.1</flyway.version>

<maven.deploy.skip>true</maven.deploy.skip>

</properties>
Expand Down

0 comments on commit 865b131

Please sign in to comment.