Skip to content

Commit

Permalink
fix: Change table name to avoid name conflicts (#437)
Browse files Browse the repository at this point in the history
* fix: Change table name to avoid name conflicts

Signed-off-by: Oleg Kopysov <[email protected]>

* fix: Change table name in documentation

Signed-off-by: Oleg Kopysov <[email protected]>

---------

Signed-off-by: Oleg Kopysov <[email protected]>
  • Loading branch information
o-kopysov authored Feb 19, 2024
1 parent c38a0fb commit 8d1e5ce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doc/quick-start-guide-and-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Before building _LPVS_ from source code, ensure that you have the following prer
mysql -u[username] -p[password] < src/main/resources/database_dump.sql
```

2.5 Fill in the `licenses` and `license_conflicts` tables with the information about permitted, restricted, and prohibited licenses, as well as their compatibility specifics. You can find an example database dump file in the repository at [`src/main/resources/database_dump.sql`](src/main/resources/database_dump.sql).
2.5 Fill in the `license_list` and `license_conflicts` tables with the information about permitted, restricted, and prohibited licenses, as well as their compatibility specifics. You can find an example database dump file in the repository at [`src/main/resources/database_dump.sql`](src/main/resources/database_dump.sql).

2.6 Update the following lines in the [`src/main/resources/application.properties`](src/main/resources/application.properties) file:
```properties
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/lpvs/entity/LPVSLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

/**
* Entity class representing licenses in the LPVS system.
* This class is mapped to the "licenses" table in the "lpvs" schema.
* This class is mapped to the "license_list" table in the "lpvs" schema.
*/
@Entity
@Table(
name = "licenses",
name = "license_list",
schema = "${lpvs.schema:lpvs}",
indexes = {@Index(name = "spdx_id", columnList = "license_spdx", unique = true)})
@Getter
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/lpvs/repository/LPVSLicenseRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface LPVSLicenseRepository extends JpaRepository<LPVSLicense, Long>
*
* @return List of {@link LPVSLicense} entities representing licenses.
*/
@Query(value = "SELECT * FROM licenses", nativeQuery = true)
@Query(value = "SELECT * FROM license_list", nativeQuery = true)
List<LPVSLicense> takeAllLicenses();

/**
Expand All @@ -37,7 +37,7 @@ public interface LPVSLicenseRepository extends JpaRepository<LPVSLicense, Long>
*/
@Query(
value =
"SELECT * FROM licenses WHERE licenses.license_spdx = :spdxId ORDER BY id DESC LIMIT 1",
"SELECT * FROM license_list WHERE license_list.license_spdx = :spdxId ORDER BY id DESC LIMIT 1",
nativeQuery = true)
LPVSLicense searchBySpdxId(@Param("spdxId") String spdxId);

Expand All @@ -49,7 +49,7 @@ public interface LPVSLicenseRepository extends JpaRepository<LPVSLicense, Long>
*/
@Query(
value =
"SELECT * FROM licenses WHERE licenses.license_alternative_names LIKE %:licenseName% ORDER BY id DESC LIMIT 1",
"SELECT * FROM license_list WHERE license_list.license_alternative_names LIKE %:licenseName% ORDER BY id DESC LIMIT 1",
nativeQuery = true)
LPVSLicense searchByAlternativeLicenseNames(@Param("licenseName") String licenseName);

Expand All @@ -58,6 +58,6 @@ public interface LPVSLicenseRepository extends JpaRepository<LPVSLicense, Long>
*
* @return List of SPDX identifiers as Strings.
*/
@Query(value = "select licenses.spdxId from LPVSLicense licenses")
@Query(value = "select license_list.spdxId from LPVSLicense license_list")
List<String> takeAllSpdxId();
}
12 changes: 6 additions & 6 deletions src/main/resources/database_dump.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE SCHEMA IF NOT EXISTS lpvs;
USE lpvs;

CREATE TABLE IF NOT EXISTS licenses (
CREATE TABLE IF NOT EXISTS license_list (
id bigint NOT NULL AUTO_INCREMENT,
license_usage varchar(255) DEFAULT NULL,
license_name varchar(255) NOT NULL,
Expand All @@ -18,8 +18,8 @@ CREATE TABLE IF NOT EXISTS license_conflicts (
PRIMARY KEY (id),
KEY (conflict_license_id),
KEY (repository_license_id),
FOREIGN KEY (conflict_license_id) REFERENCES licenses (id),
FOREIGN KEY (repository_license_id) REFERENCES licenses (id)
FOREIGN KEY (conflict_license_id) REFERENCES license_list (id),
FOREIGN KEY (repository_license_id) REFERENCES license_list (id)
);

CREATE TABLE IF NOT EXISTS pull_requests (
Expand Down Expand Up @@ -60,9 +60,9 @@ CREATE TABLE IF NOT EXISTS detected_license (
KEY (repository_license_id),
KEY (conflict_id),
FOREIGN KEY (conflict_id) REFERENCES license_conflicts (id),
FOREIGN KEY (license_id) REFERENCES licenses (id),
FOREIGN KEY (license_id) REFERENCES license_list (id),
FOREIGN KEY (pull_request_id) REFERENCES pull_requests (id),
FOREIGN KEY (repository_license_id) REFERENCES licenses (id)
FOREIGN KEY (repository_license_id) REFERENCES license_list (id)
);

CREATE TABLE IF NOT EXISTS queue (
Expand Down Expand Up @@ -91,7 +91,7 @@ CREATE TABLE IF NOT EXISTS member (
UNIQUE (email,provider)
);

INSERT INTO licenses (license_name, license_spdx, license_usage) VALUES
INSERT INTO license_list (license_name, license_spdx, license_usage) VALUES
('GNU General Public License v3.0 only','GPL-3.0-only','PROHIBITED'),
('OpenSSL License','OpenSSL','PERMITTED'),
('GNU Lesser General Public License v2.0 or later','LGPL-2.0-or-later','RESTRICTED'),
Expand Down

0 comments on commit 8d1e5ce

Please sign in to comment.