beta keys schema wip

This commit is contained in:
Brandon Thomas committed 2024-05-12 23:51:31 -07:00
1 parent f7b47dea0d
commit d69735712a
2 files changed
+57 -2

No files matched your search

@@ -1 +1,5 @@
-- This file should undo anything in `up.sql`
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
DROP TABLE beta_keys;
@@ -1 +1,52 @@
-- Your SQL goes here
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
CREATE TABLE beta_keys (
-- Not used for anything except replication.
id BIGINT(20) NOT NULL AUTO_INCREMENT,
-- ========== PRIMARY, FOREIGN KEYS, and POLYMORPHISM ==========
-- Effective "primary key" of the beta key.
token VARCHAR(32) NOT NULL,
-- ========== KEY INFO ==========
-- Name of the product the key applies to
product_name VARCHAR(32) NOT NULL,
-- The actual key value that the user inputs.
-- Crockford-encoded.
key_value VARCHAR(32) DEFAULT NULL,
-- ========== USERS ==========
-- The user that redeems the beta key.
-- If set, the key has been redeemed.
maybe_redeemer_user_token VARCHAR(32) DEFAULT NULL,
-- The user that redeems the beta key.
-- Based on a cookie sent by the frontend.
maybe_redeemer_anonymous_visitor_token VARCHAR(32) DEFAULT NULL,
-- The user that redeems the beta key.
-- Wide enough for IPv4/6
maybe_redeemer_ip_address VARCHAR(40) DEFAULT NULL,
-- ========== TIMESTAMPS ==========
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
maybe_redeemed_at TIMESTAMP NULL,
-- INDICES --
PRIMARY KEY (id),
UNIQUE KEY (entity_type, entity_token),
KEY index_maybe_sort_order_asc (maybe_sort_order ASC),
KEY index_maybe_sort_order_desc (maybe_sort_order DESC),
KEY index_created_at (created_at),
KEY index_deleted_at (deleted_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;