2023031700-add_user_money_log.php 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. use App\Interfaces\MigrationInterface;
  4. use App\Services\DB;
  5. return new class() implements MigrationInterface {
  6. public function up(): int
  7. {
  8. DB::getPdo()->exec("CREATE TABLE IF NOT EXISTS `user_money_log` (
  9. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  10. `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
  11. `before` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动前账户余额',
  12. `after` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动后账户余额',
  13. `amount` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变动总额',
  14. `remark` text NOT NULL DEFAULT '' COMMENT '备注',
  15. `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
  16. PRIMARY KEY (`id`),
  17. KEY `user_id` (`user_id`)
  18. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
  19. return 2023031700;
  20. }
  21. public function down(): int
  22. {
  23. DB::getPdo()->exec('DROP TABLE IF EXISTS `user_money_log`;');
  24. return 2023030500;
  25. }
  26. };