1 /*
2  * Copyright 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package androidx.work.impl.model
17 
18 import androidx.annotation.RestrictTo
19 import androidx.room.ColumnInfo
20 import androidx.room.Entity
21 import androidx.room.ForeignKey
22 import androidx.room.Index
23 
24 /** Database entity that defines a mapping from a tag to a [WorkSpec] id. */
25 @Entity(
26     foreignKeys =
27         [
28             ForeignKey(
29                 entity = WorkSpec::class,
30                 parentColumns = ["id"],
31                 childColumns = ["work_spec_id"],
32                 onDelete = ForeignKey.CASCADE,
33                 onUpdate = ForeignKey.CASCADE
34             )
35         ],
36     primaryKeys = ["tag", "work_spec_id"],
37     indices = [Index(value = ["work_spec_id"])]
38 )
39 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
40 class WorkTag(
41     @ColumnInfo(name = "tag") val tag: String,
42     @ColumnInfo(name = "work_spec_id") val workSpecId: String
43 )
44