30 lines
1.2 KiB
SQL
30 lines
1.2 KiB
SQL
-- SQL for the License Manager Database
|
|
-- Create a new database called 'license_manager_db' and run this script.
|
|
|
|
CREATE TABLE IF NOT EXISTS licenses (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
license_key VARCHAR(255) UNIQUE NOT NULL,
|
|
max_activations INT DEFAULT 1,
|
|
max_counters INT DEFAULT 1,
|
|
status ENUM('active', 'suspended', 'expired') DEFAULT 'active',
|
|
owner VARCHAR(255),
|
|
address TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE IF NOT EXISTS activations (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
license_id INT NOT NULL,
|
|
fingerprint VARCHAR(255) NOT NULL,
|
|
domain VARCHAR(255),
|
|
product VARCHAR(255),
|
|
activated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (license_id) REFERENCES licenses(id) ON DELETE CASCADE,
|
|
UNIQUE KEY (license_id, fingerprint)
|
|
) ENGINE=InnoDB;
|
|
|
|
-- Seed some test data
|
|
INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-8822-1192-3301', 1, 1, 'Client A');
|
|
INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-TEST-KEY-0001', 5, 10, 'Test User');
|
|
INSERT INTO licenses (license_key, max_activations, max_counters, owner) VALUES ('FLAT-DEV-UNLIMITED', 999, 999, 'Developer');
|