1 /*
2  * Copyright 2019 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.PrimaryKey
23 import androidx.work.Data
24 
25 /** A Database entity which stores progress of a given [WorkSpec] id. */
26 @Entity(
27     foreignKeys =
28         [
29             ForeignKey(
30                 entity = WorkSpec::class,
31                 parentColumns = ["id"],
32                 childColumns = ["work_spec_id"],
33                 onDelete = ForeignKey.CASCADE,
34                 onUpdate = ForeignKey.CASCADE
35             )
36         ]
37 )
38 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
39 class WorkProgress(
40     @ColumnInfo(name = "work_spec_id") @PrimaryKey val workSpecId: String,
41     @ColumnInfo(name = "progress") val progress: Data
42 )
43