Before running the application, you must have a running instance of Redis and MySQL. Use the following SQL commands to initialize the required databases and tables:
- Create two databases:
test and test2. - Create the
account table in test. - Create the
moment table in test. - Create the
comment table in test2.
create database test;
CREATE TABLE `account` (
`user_id` varchar(127) NOT NULL DEFAULT '',
`user_name` varchar(127) NOT NULL DEFAULT '',
`password` varchar(127) NOT NULL DEFAULT '',
`gmt_created` datetime NOT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`user_id`),
KEY `index_user_id` (`user_id`) KEY_BLOCK_SIZE=10
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `moment` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci,
`gmt_created` datetime NOT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_deleted` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `index_user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
create database test2;
CREATE TABLE `comment` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`moment_id` bigint(20) unsigned NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci,
`gmt_created` datetime NOT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_deleted` tinyint(1) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `index_moment_id` (`moment_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;