Merge branch 'feature/tag-table'
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE `Tags`
|
||||
(
|
||||
`id` int PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` varchar(50) NOT NULL,
|
||||
`note_id` int NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `Tags`
|
||||
ADD FOREIGN KEY (`note_id`) REFERENCES `Notes` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
@@ -0,0 +1,11 @@
|
||||
package be.vandewalleh.entities
|
||||
|
||||
import me.liuwj.ktorm.entity.Entity
|
||||
|
||||
interface Tag : Entity<Tag> {
|
||||
companion object : Entity.Factory<Tag>()
|
||||
|
||||
val id: Int
|
||||
var name: String
|
||||
var note: Note
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package be.vandewalleh.tables
|
||||
|
||||
import be.vandewalleh.entities.Tag
|
||||
import me.liuwj.ktorm.schema.Table
|
||||
import me.liuwj.ktorm.schema.int
|
||||
import me.liuwj.ktorm.schema.varchar
|
||||
|
||||
object Tags : Table<Tag>("Tags") {
|
||||
val id by int("id").primaryKey().bindTo { it.id }
|
||||
val name by varchar("name").bindTo { it.name }
|
||||
val noteId by int("note_id").references(Notes) { it.note }
|
||||
}
|
||||
Reference in New Issue
Block a user