<?php

namespace GemBoards\Database;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use GemBoards\Utils\Helper;

class CreateNotifiedUsersTable {
	public static function up( $prefix, $charset_collate ) {
		$table_name = $prefix . Helper::BOARDS_NOTIFIED_USER_TABLE;
		$sql        = "CREATE TABLE $table_name (
				id            BIGINT(20) UNSIGNED AUTO_INCREMENT,
				to_user_id    BIGINT(20) UNSIGNED NOT NULL, 
				notification_id BIGINT(20) UNSIGNED NULL,
				is_read       TINYINT(1) DEFAULT 0,
				created_at    TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
                PRIMARY KEY (id),
				KEY idx_ntf_usr (to_user_id, notification_id,  is_read)
		) $charset_collate;";
		dbDelta( $sql );
	}
}
