mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-02-15 20:33:26 +00:00
Setup space entities
This commit is contained in:
parent
4d38bf7e69
commit
13ad5e3219
@ -0,0 +1,30 @@
|
||||
CREATE TABLE "space" (
|
||||
"id" varchar(254) not null primary key,
|
||||
"name" varchar(254) not null,
|
||||
"cid" varchar(254) not null,
|
||||
"owner" varchar(254) not null,
|
||||
"created" timestamp not null,
|
||||
unique ("name", "cid"),
|
||||
foreign key ("cid") references "collective"("cid"),
|
||||
foreign key ("owner") references "user_"("uid")
|
||||
);
|
||||
|
||||
CREATE TABLE "space_member" (
|
||||
"id" varchar(254) not null primary key,
|
||||
"space_id" varchar(254) not null,
|
||||
"user_id" varchar(254) not null,
|
||||
"created" timestamp not null,
|
||||
unique ("space_id", "user_id"),
|
||||
foreign key ("space_id") references "space"("id"),
|
||||
foreign key ("user_id") references "user_"("uid")
|
||||
);
|
||||
|
||||
CREATE TABLE "space_item" (
|
||||
"id" varchar(254) not null primary key,
|
||||
"space_id" varchar(254) not null,
|
||||
"item_id" varchar(254) not null,
|
||||
"created" timestamp not null,
|
||||
unique ("space_id", "item_id"),
|
||||
foreign key ("space_id") references "space"("id"),
|
||||
foreign key ("item_id") references "item"("itemid")
|
||||
);
|
@ -0,0 +1,44 @@
|
||||
package docspell.store.records
|
||||
|
||||
import docspell.common._
|
||||
import docspell.store.impl.Column
|
||||
import docspell.store.impl.Implicits._
|
||||
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
|
||||
case class RSpace(
|
||||
id: Ident,
|
||||
name: String,
|
||||
collectiveId: Ident,
|
||||
owner: Ident,
|
||||
created: Timestamp
|
||||
)
|
||||
|
||||
object RSpace {
|
||||
|
||||
val table = fr"space"
|
||||
|
||||
object Columns {
|
||||
|
||||
val id = Column("id")
|
||||
val name = Column("name")
|
||||
val collective = Column("cid")
|
||||
val owner = Column("owner")
|
||||
val created = Column("created")
|
||||
|
||||
val all = List(id, name, collective, owner, created)
|
||||
}
|
||||
|
||||
import Columns._
|
||||
|
||||
def insert(value: RSpace): ConnectionIO[Int] = {
|
||||
val sql = insertRow(
|
||||
table,
|
||||
all,
|
||||
fr"${value.id},${value.name},${value.collectiveId},${value.owner},${value.created}"
|
||||
)
|
||||
sql.update.run
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package docspell.store.records
|
||||
|
||||
import docspell.common._
|
||||
import docspell.store.impl.Column
|
||||
import docspell.store.impl.Implicits._
|
||||
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
|
||||
case class RSpaceItem(
|
||||
id: Ident,
|
||||
spaceId: Ident,
|
||||
itemId: Ident,
|
||||
created: Timestamp
|
||||
)
|
||||
|
||||
object RSpaceItem {
|
||||
|
||||
val table = fr"space"
|
||||
|
||||
object Columns {
|
||||
|
||||
val id = Column("id")
|
||||
val space = Column("space_id")
|
||||
val item = Column("user_id")
|
||||
val created = Column("created")
|
||||
|
||||
val all = List(id, space, user, created)
|
||||
}
|
||||
|
||||
import Columns._
|
||||
|
||||
def insert(value: RSpaceItem): ConnectionIO[Int] = {
|
||||
val sql = insertRow(
|
||||
table,
|
||||
all,
|
||||
fr"${value.id},${value.spaceId},${value.itemId},${value.created}"
|
||||
)
|
||||
sql.update.run
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package docspell.store.records
|
||||
|
||||
import docspell.common._
|
||||
import docspell.store.impl.Column
|
||||
import docspell.store.impl.Implicits._
|
||||
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
|
||||
case class RSpaceMember(
|
||||
id: Ident,
|
||||
spaceId: Ident,
|
||||
userId: Ident,
|
||||
created: Timestamp
|
||||
)
|
||||
|
||||
object RSpaceMember {
|
||||
|
||||
val table = fr"space"
|
||||
|
||||
object Columns {
|
||||
|
||||
val id = Column("id")
|
||||
val space = Column("space_id")
|
||||
val user = Column("user_id")
|
||||
val created = Column("created")
|
||||
|
||||
val all = List(id, space, user, created)
|
||||
}
|
||||
|
||||
import Columns._
|
||||
|
||||
def insert(value: RSpaceMember): ConnectionIO[Int] = {
|
||||
val sql = insertRow(
|
||||
table,
|
||||
all,
|
||||
fr"${value.id},${value.spaceId},${value.userId},${value.created}"
|
||||
)
|
||||
sql.update.run
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user