db: upgrade to 21, add markdownMode column

main
Alibek Omarov 5 years ago
parent 793c21eb85
commit 74ea67627c
  1. 2
      app/src/main/java/com/keylesspalace/tusky/TuskyApplication.java
  2. 9
      app/src/main/java/com/keylesspalace/tusky/db/AppDatabase.java
  3. 12
      app/src/main/java/com/keylesspalace/tusky/db/TootEntity.java

@ -72,7 +72,7 @@ public class TuskyApplication extends Application implements HasAndroidInjector
AppDatabase.MIGRATION_11_12, AppDatabase.MIGRATION_12_13, AppDatabase.MIGRATION_10_13, AppDatabase.MIGRATION_11_12, AppDatabase.MIGRATION_12_13, AppDatabase.MIGRATION_10_13,
AppDatabase.MIGRATION_13_14, AppDatabase.MIGRATION_14_15, AppDatabase.MIGRATION_15_16, AppDatabase.MIGRATION_13_14, AppDatabase.MIGRATION_14_15, AppDatabase.MIGRATION_15_16,
AppDatabase.MIGRATION_16_17, AppDatabase.MIGRATION_17_18, AppDatabase.MIGRATION_18_19, AppDatabase.MIGRATION_16_17, AppDatabase.MIGRATION_17_18, AppDatabase.MIGRATION_18_19,
AppDatabase.MIGRATION_19_20) AppDatabase.MIGRATION_19_20, AppDatabase.MIGRATION_20_21)
.build(); .build();
accountManager = new AccountManager(appDatabase); accountManager = new AccountManager(appDatabase);
serviceLocator = new ServiceLocator() { serviceLocator = new ServiceLocator() {

@ -30,7 +30,7 @@ import androidx.annotation.NonNull;
@Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class, @Database(entities = {TootEntity.class, AccountEntity.class, InstanceEntity.class, TimelineStatusEntity.class,
TimelineAccountEntity.class, ConversationEntity.class TimelineAccountEntity.class, ConversationEntity.class
}, version = 20) }, version = 21)
public abstract class AppDatabase extends RoomDatabase { public abstract class AppDatabase extends RoomDatabase {
public abstract TootDao tootDao(); public abstract TootDao tootDao();
@ -318,4 +318,11 @@ public abstract class AppDatabase extends RoomDatabase {
} }
}; };
public static final Migration MIGRATION_20_21 = new Migration(20, 21) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `TootEntity` ADD COLUMN `markdownMode` INTEGER");
}
};
} }

@ -66,9 +66,13 @@ public class TootEntity {
@ColumnInfo(name = "poll") @ColumnInfo(name = "poll")
private final NewPoll poll; private final NewPoll poll;
@Nullable
@ColumnInfo(name = "markdownMode")
private final Boolean markdownMode;
public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId, public TootEntity(int uid, String text, String urls, String descriptions, String contentWarning, String inReplyToId,
@Nullable String inReplyToText, @Nullable String inReplyToUsername, @Nullable String inReplyToText, @Nullable String inReplyToUsername,
Status.Visibility visibility, @Nullable NewPoll poll) { Status.Visibility visibility, @Nullable NewPoll poll, @Nullable Boolean markdownMode) {
this.uid = uid; this.uid = uid;
this.text = text; this.text = text;
this.urls = urls; this.urls = urls;
@ -79,6 +83,7 @@ public class TootEntity {
this.inReplyToUsername = inReplyToUsername; this.inReplyToUsername = inReplyToUsername;
this.visibility = visibility; this.visibility = visibility;
this.poll = poll; this.poll = poll;
this.markdownMode = markdownMode;
} }
public String getText() { public String getText() {
@ -124,6 +129,11 @@ public class TootEntity {
return poll; return poll;
} }
@Nullable
public Boolean getMarkdownMode() {
return markdownMode;
}
public static final class Converters { public static final class Converters {
private static final Gson gson = new Gson(); private static final Gson gson = new Gson();

Loading…
Cancel
Save