Merge branch 'feature/tag-table'
This commit is contained in:
commit
3b54213166
9
api/resources/db/migration/V3__Create_tag_table.sql
Normal file
9
api/resources/db/migration/V3__Create_tag_table.sql
Normal 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
11
api/src/entities/Tag.kt
Normal 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
12
api/src/tables/Tags.kt
Normal 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 }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user