package com.nbusy.app.data.sqldb;

import android.provider.BaseColumns;

public final class SQLTables {

    private SQLTables() {
    }

    private static final String COMMA_SEP = ",";

    private static final String TEXT_TYPE = " TEXT";
    private static final String BLOB_TYPE = " BLOB";
    private static final String INTEGER_TYPE = " INTEGER";

    public static final String CREATE_PROFILE_TABLE =
            "CREATE TABLE " + ProfileTable.TABLE_NAME + " (" +
                    ProfileTable._ID + " TEXT PRIMARY KEY," +
                    ProfileTable.JWT_TOKEN + TEXT_TYPE + COMMA_SEP +
                    ProfileTable.NAME + TEXT_TYPE + COMMA_SEP +
                    ProfileTable.EMAIL + TEXT_TYPE + COMMA_SEP +
                    ProfileTable.PICTURE + BLOB_TYPE +
                    ")";

    public static final String CREATE_CHATS_TABLE =
            "CREATE TABLE " + ChatsTable.TABLE_NAME + " (" +
                    ChatsTable._ID + " TEXT PRIMARY KEY," +
                    ChatsTable.PEER_NAME + TEXT_TYPE + COMMA_SEP +
                    ChatsTable.LAST_MESSAGE + TEXT_TYPE + COMMA_SEP +
                    ChatsTable.LAST_MESSAGE_SENT + INTEGER_TYPE + COMMA_SEP +
                    "FOREIGN KEY(" + ChatsTable.TABLE_NAME + ProfileTable.TABLE_NAME + ") REFERENCES " + ProfileTable.TABLE_NAME + "(" + ProfileTable._ID + ")" +
                    ")";

    public static final String DROP_PROFILE_TABLE = "DROP TABLE IF EXISTS " + ProfileTable.TABLE_NAME;
    public static final String DROP_CHATS_TABLE = "DROP TABLE IF EXISTS " + ChatsTable.TABLE_NAME;

    public static abstract class ProfileTable implements BaseColumns {
        public static final String TABLE_NAME = "user_profile";
        public static final String JWT_TOKEN = "jwt_token";
        public static final String NAME = "name";
        public static final String EMAIL = "email";
        public static final String PICTURE = "picture";
    }

    public static abstract class ChatsTable implements BaseColumns {
        public static final String TABLE_NAME = "chats";
        public static final String PEER_NAME = "peer_name";
        public static final String LAST_MESSAGE = "last_message";
        public static final String LAST_MESSAGE_SENT = "last_message_sent";
    }
}

@@ -1218,136 +1218,591 @@
    %22
-FOREIGN KEY(%22 + ChatsTable.TABLE_NAME + ProfileTable.TABLE_NAME + %22) REFERENCES %22 + ProfileTable.TABLE_NAME + %22(%22 + ProfileTable
+)%22;%0A%0A    public static final String CREATE_MESSAGES_TABLE =%0A            %22CREATE TABLE %22 + ProfileTable.TABLE_NAME + %22 (%22 +%0A                    ProfileTable._ID + %22 TEXT PRIMARY KEY,%22 +%0A                    ProfileTable.JWT_TOKEN + TEXT_TYPE + COMMA_SEP +%0A                    ProfileTable.NAME + TEXT_TYPE + COMMA_SEP +%0A                    ProfileTable.EMAIL + TEXT_TYPE + COMMA_SEP +%0A                    ProfileTable.PICTURE + BLOB_TYPE + /* COMMA_SEP +%0A                    %22FOREIGN KEY(%22 + ProfileTable.TABLE_NAME + Chats.TABLE_NAME + %22) REFERENCES %22 + Chats.TABLE_NAME + %22(%22 + Chats
 ._ID
@@ -1809,16 +1809,19 @@
  + %22)%22 +
+ */
 %0A       

add CREATE_MESSAGES_TABLE script