<?php

namespace GemBoards\Database;

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

use GemBoards\Utils\Helper;

class CreateNotificationTable {
	public static function up( $prefix, $charset_collate ) {
		$table_name = $prefix . Helper::BOARDS_NOTIFICATION_TABLE;
		$sql        = "CREATE TABLE $table_name (
				id            BIGINT(20) UNSIGNED AUTO_INCREMENT,
				from_user_id  BIGINT(20) UNSIGNED NULL,
				object_id     BIGINT(20) UNSIGNED NULL,
				object_type   VARCHAR(100) NULL,
				event_type    VARCHAR(100) NULL,
				message       LONGTEXT,
                meta          longtext,
				created_at    TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
                PRIMARY KEY (id),
				KEY idx_ntf (from_user_id, event_type(50), object_id)
		) $charset_collate;";
		dbDelta( $sql );
	}

}
