diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index f770834..c153c0c 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -13,8 +13,10 @@ spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password=password spring.jpa.database-platform=org.hibernate.dialect.H2Dialect -spring.jpa.hibernate.ddl-auto=update - +spring.jpa.hibernate.ddl-auto=none +spring.sql.init.mode=always +spring.sql.init.schema-locations=classpath:schema.sql +spring.sql.init.data-locations=classpath:data.sql spring.jpa.show-sql=false # Security diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..7407e8f --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1,10 @@ +INSERT INTO post (title, content, slug, is_published, published_at, intro) VALUES + ('The Impact of Climate Change on Wildlife', + 'Climate change is profoundly affecting wildlife across the globe. Rising temperatures, shifting weather patterns, and altered habitats are forcing many species to adapt, migrate, or face the risk of extinction. Polar bears, coral reefs, and migratory birds are just a few examples of wildlife impacted by these environmental changes. Conservation efforts are increasingly focusing on mitigating these effects through habitat protection, climate action, and raising awareness about the interconnectedness of ecosystems. The survival of countless species depends on how effectively humanity addresses climate change in the coming decades.', + 'impact-of-climate-change-on-wildlife', TRUE, CURRENT_TIMESTAMP, + 'Examining how climate change is threatening wildlife and what can be done to protect vulnerable species.'), + + ('The Evolution of Digital Communication', + 'Digital communication has transformed how people connect, share ideas, and conduct business worldwide. From the invention of email and instant messaging to the rise of social media platforms, the way we communicate has become faster, more accessible, and often more visual. This evolution has bridged distances, enabling global collaboration and real-time interaction. However, it also presents challenges such as information overload, privacy concerns, and the spread of misinformation. Understanding the history and impact of digital communication is essential as society continues to navigate its benefits and pitfalls.', + 'the-evolution-of-digital-communication', TRUE, CURRENT_TIMESTAMP, + 'A comprehensive look at how digital communication has changed our world and the challenges it presents.'); diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql new file mode 100644 index 0000000..efdd938 --- /dev/null +++ b/src/main/resources/schema.sql @@ -0,0 +1,21 @@ +CREATE TABLE IF NOT EXISTS post ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + title VARCHAR(255), + content CLOB, + slug VARCHAR(255) NOT NULL UNIQUE, + is_published BOOLEAN, + published_at TIMESTAMP, + intro VARCHAR(400) +); +CREATE TABLE IF NOT EXISTS project ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + name VARCHAR(255), + description VARCHAR(255) +); +CREATE TABLE IF NOT EXISTS users ( + id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + username VARCHAR(255), + password VARCHAR(255), + firstName VARCHAR(255), + lastName VARCHAR(255) +);