Merge branch 'feature/tag-table'

This commit is contained in:
Hubert Van De Walle 2020-04-12 18:01:37 +02:00
commit 3b54213166
3 changed files with 32 additions and 0 deletions

View File

@ -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;

11
api/src/entities/Tag.kt Normal file
View File

@ -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
}

12
api/src/tables/Tags.kt Normal file
View File

@ -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 }
}