Add Chapters table
This commit is contained in:
parent
e0ffbad105
commit
0dd4886846
@ -1,9 +1,13 @@
|
|||||||
CREATE TABLE `Tags`
|
CREATE TABLE `Chapters`
|
||||||
(
|
(
|
||||||
`id` int PRIMARY KEY AUTO_INCREMENT,
|
`id` int PRIMARY KEY AUTO_INCREMENT,
|
||||||
`name` varchar(50) NOT NULL,
|
`number` int NOT NULL,
|
||||||
|
`content` text NOT NULL,
|
||||||
`note_id` int NOT NULL
|
`note_id` int NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE `Tags`
|
ALTER TABLE `Chapters`
|
||||||
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||||
|
|
||||||
|
ALTER TABLE `Notes`
|
||||||
|
DROP COLUMN `content`;
|
||||||
12
api/src/entities/Chapter.kt
Normal file
12
api/src/entities/Chapter.kt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package be.vandewalleh.entities
|
||||||
|
|
||||||
|
import me.liuwj.ktorm.entity.Entity
|
||||||
|
|
||||||
|
interface Chapter : Entity<Chapter> {
|
||||||
|
companion object : Entity.Factory<Chapter>()
|
||||||
|
|
||||||
|
val id: Int
|
||||||
|
var number: Int
|
||||||
|
var content: String
|
||||||
|
var note: Note
|
||||||
|
}
|
||||||
15
api/src/tables/Chapters.kt
Normal file
15
api/src/tables/Chapters.kt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package be.vandewalleh.tables
|
||||||
|
|
||||||
|
import be.vandewalleh.entities.Chapter
|
||||||
|
import be.vandewalleh.entities.Tag
|
||||||
|
import me.liuwj.ktorm.schema.Table
|
||||||
|
import me.liuwj.ktorm.schema.int
|
||||||
|
import me.liuwj.ktorm.schema.text
|
||||||
|
import me.liuwj.ktorm.schema.varchar
|
||||||
|
|
||||||
|
object Chapters : Table<Chapter>("Chapters") {
|
||||||
|
val id by int("id").primaryKey().bindTo { it.id }
|
||||||
|
val number by int("number").bindTo { it.number }
|
||||||
|
val content by text("content").bindTo { it.content }
|
||||||
|
val noteId by int("note_id").references(Notes) { it.note }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user