diff --git a/src/main/java/space/kklochko/jdbc_hospital_example/db/repositories/blocks/TurnOnUUIDPlugin.java b/src/main/java/space/kklochko/jdbc_hospital_example/db/repositories/blocks/TurnOnUUIDPlugin.java new file mode 100644 index 0000000..a7f96be --- /dev/null +++ b/src/main/java/space/kklochko/jdbc_hospital_example/db/repositories/blocks/TurnOnUUIDPlugin.java @@ -0,0 +1,19 @@ +package space.kklochko.jdbc_hospital_example.db.repositories.blocks; + +import space.kklochko.jdbc_hospital_example.db.factories.DataBaseConnection; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +public class TurnOnUUIDPlugin { + public boolean create(DataBaseConnection db) { + try (Connection connection = db.connect()) { + Statement statement = connection.createStatement(); + statement.execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";"); + return true; + } catch (SQLException e) { + throw new RuntimeException(e); + } + } +}