Set initial database schema
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package net.kpuig.concord.backend.datamodels;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Data;
|
||||
import net.kpuig.concord.backend.datamodels.enums.ChannelType;
|
||||
|
||||
@Data
|
||||
@Entity(name = "channel")
|
||||
public class Channel {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private Long position;
|
||||
|
||||
private ChannelType type;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
private Server server;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.kpuig.concord.backend.datamodels;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "message")
|
||||
public class Message {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String content;
|
||||
|
||||
private Long timestamp;
|
||||
|
||||
@ManyToOne
|
||||
private UserProfile userProfile;
|
||||
|
||||
@ManyToOne
|
||||
private Channel channel;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.kpuig.concord.backend.datamodels;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "server")
|
||||
public class Server {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private URL image;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.kpuig.concord.backend.datamodels;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Entity(name = "user_profile")
|
||||
public class UserProfile {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.kpuig.concord.backend.datamodels.enums;
|
||||
|
||||
public enum ChannelType {
|
||||
TEXT_CHANNEL,
|
||||
VOICE_CHANNEL
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.kpuig.concord.backend.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import net.kpuig.concord.backend.datamodels.Channel;
|
||||
|
||||
public interface ChannelRepository extends JpaRepository<Channel, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.kpuig.concord.backend.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import net.kpuig.concord.backend.datamodels.Message;
|
||||
|
||||
public interface MessageRepository extends JpaRepository<Message, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.kpuig.concord.backend.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import net.kpuig.concord.backend.datamodels.Server;
|
||||
|
||||
public interface ServerRepository extends JpaRepository<Server, Long> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.kpuig.concord.backend.repositories;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import net.kpuig.concord.backend.datamodels.UserProfile;
|
||||
|
||||
public interface UserProfileRepository extends JpaRepository<UserProfile, Long> {
|
||||
|
||||
}
|
||||
@@ -1 +1,11 @@
|
||||
spring.application.name=backend
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2-console
|
||||
spring.datasource.url=jdbc:h2:mem:testdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=password
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
logging.level.org.springframework=INFO
|
||||
logging.level.com.example=DEBUG
|
||||
server.port=8080
|
||||
Reference in New Issue
Block a user