diff --git a/pom.xml b/pom.xml
index 0c754f19..6085b3d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,10 +37,26 @@
spring-boot-starter-data-jpa
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
com.h2database
h2
+
+
+ mysql
+ mysql-connector-java
+ 8.0.33
+
+
+
+ org.projectlombok
+ lombok
+
@@ -68,6 +84,22 @@
false
+
+ org.liquibase
+ liquibase-maven-plugin
+ ${liquibase.version}
+
+
+ process-resources
+
+ src/main/resources/liquibase.properties
+
+
+ update
+
+
+
+
diff --git a/src/main/java/mate/academy/rickandmorty/controller/RickAndMortyController.java b/src/main/java/mate/academy/rickandmorty/controller/RickAndMortyController.java
new file mode 100644
index 00000000..3fe47f5e
--- /dev/null
+++ b/src/main/java/mate/academy/rickandmorty/controller/RickAndMortyController.java
@@ -0,0 +1,25 @@
+package mate.academy.rickandmorty.controller;
+
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import mate.academy.rickandmorty.model.Personage;
+import mate.academy.rickandmorty.repository.PersonageRepository;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/rick-and-morty")
+@RequiredArgsConstructor
+public class RickAndMortyController {
+ private final PersonageRepository characterRepository;
+
+ @GetMapping("/random-personage")
+ public Object getRandomPersonage() {
+ return characterRepository;
+ }
+
+ @GetMapping("/search")
+ public List getPersonageByName(@RequestParam String name) {
+ return characterRepository.findAllByNameLike(name);
+ }
+}
diff --git a/src/main/java/mate/academy/rickandmorty/model/Personage.java b/src/main/java/mate/academy/rickandmorty/model/Personage.java
new file mode 100644
index 00000000..6b7e11c7
--- /dev/null
+++ b/src/main/java/mate/academy/rickandmorty/model/Personage.java
@@ -0,0 +1,29 @@
+package mate.academy.rickandmorty.model;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import lombok.Data;
+
+@Entity
+@Data
+@Table(name = "personages")
+public class Personage {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @Column(name = "external_id", nullable = false)
+ private Long externalId;
+
+ @Column(nullable = false)
+ private String name;
+
+ @Column(nullable = false)
+ private String status;
+
+ private String gender;
+}
diff --git a/src/main/java/mate/academy/rickandmorty/repository/PersonageRepository.java b/src/main/java/mate/academy/rickandmorty/repository/PersonageRepository.java
new file mode 100644
index 00000000..b461ee6d
--- /dev/null
+++ b/src/main/java/mate/academy/rickandmorty/repository/PersonageRepository.java
@@ -0,0 +1,9 @@
+package mate.academy.rickandmorty.repository;
+
+import java.util.List;
+import mate.academy.rickandmorty.model.Personage;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface PersonageRepository extends JpaRepository {
+ List findAllByNameLike(String name);
+}
diff --git a/src/main/java/mate/academy/rickandmorty/service/RickAndMortyApiService.java b/src/main/java/mate/academy/rickandmorty/service/RickAndMortyApiService.java
new file mode 100644
index 00000000..c94a89c4
--- /dev/null
+++ b/src/main/java/mate/academy/rickandmorty/service/RickAndMortyApiService.java
@@ -0,0 +1,8 @@
+package mate.academy.rickandmorty.service;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class RickAndMortyApiService {
+
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8b137891..58fbcf06 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1,9 @@
+spring.datasource.url=jdbc:mysql://localhost/rick_and_morty?serverTimezone=UTC
+spring.datasource.username=root
+spring.datasource.password=1234
+spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
+spring.jpa.hibernate.ddl-auto=validate
+spring.jpa.show-sql=true
+
+spring.jpa.open-in-view=false
diff --git a/src/main/resources/db/changelog/changes/01-create-characters-table.yaml b/src/main/resources/db/changelog/changes/01-create-characters-table.yaml
new file mode 100644
index 00000000..6f566b42
--- /dev/null
+++ b/src/main/resources/db/changelog/changes/01-create-characters-table.yaml
@@ -0,0 +1,33 @@
+databaseChangeLog:
+ - changeSet:
+ id: create-characters-table
+ author: teract10s
+ changes:
+ - createTable:
+ tableName: characters
+ columns:
+ - column:
+ name: id
+ type: bigint
+ autoIncrement: true
+ constraints:
+ primaryKey: true
+ nullable: false
+ - column:
+ name: external_id
+ type: bigint
+ constraints:
+ nullable: false
+ - column:
+ name: name
+ type: varchar(255)
+ constraints:
+ nullable: false
+ - column:
+ name: status
+ type: varchar(255)
+ constraints:
+ nullable: false
+ - column:
+ name: gender
+ type: varchar(255)
diff --git a/src/main/resources/db/changelog/changes/02-rename-characters-to-personages.yaml b/src/main/resources/db/changelog/changes/02-rename-characters-to-personages.yaml
new file mode 100644
index 00000000..d3ae94a2
--- /dev/null
+++ b/src/main/resources/db/changelog/changes/02-rename-characters-to-personages.yaml
@@ -0,0 +1,8 @@
+databaseChangeLog:
+ - changeSet:
+ id: rename-characters-to-personages
+ author: teract10s
+ changes:
+ - renameTable:
+ oldTableName: characters
+ newTableName: personages
diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml
new file mode 100644
index 00000000..16f714e8
--- /dev/null
+++ b/src/main/resources/db/changelog/db.changelog-master.yaml
@@ -0,0 +1,5 @@
+databaseChangeLog:
+ - include:
+ file: db/changelog/changes/01-create-characters-table.yaml
+ - include:
+ file: db/changelog/changes/02-rename-characters-to-personages.yaml
diff --git a/src/main/resources/liquibase.properties b/src/main/resources/liquibase.properties
new file mode 100644
index 00000000..1187c950
--- /dev/null
+++ b/src/main/resources/liquibase.properties
@@ -0,0 +1,5 @@
+url=jdbc:mysql://localhost/rick_and_morty?serverTimezone=UTC
+username=root
+password=1234
+changeLogFile=db/changelog/db.changelog-master.yaml
+driver=com.mysql.cj.jdbc.Driver