-- ScriptShare Database Initialization Script -- This script sets up the initial database structure and default data USE scriptshare; -- Create tables if they don't exist (will be handled by Drizzle migrations) -- This file can be used for any initial data setup -- Insert default admin user (optional) -- Note: Password should be properly hashed in production INSERT IGNORE INTO users (id, email, username, displayName, isAdmin, isModerator, createdAt, updatedAt) VALUES ( 'admin-default-id', 'admin@scriptshare.local', 'admin', 'Administrator', true, true, NOW(), NOW() ); -- Insert sample categories INSERT IGNORE INTO script_categories (name, description) VALUES ('System Administration', 'Scripts for system administration tasks'), ('Development', 'Development and build automation scripts'), ('Backup & Recovery', 'Backup and recovery automation'), ('Monitoring', 'System and application monitoring scripts'), ('Security', 'Security and audit scripts'), ('Database', 'Database management and maintenance'), ('Network', 'Network configuration and management'), ('DevOps', 'DevOps and CI/CD automation'); -- Create indexes for performance CREATE INDEX IF NOT EXISTS idx_scripts_author ON scripts(authorId); CREATE INDEX IF NOT EXISTS idx_scripts_created ON scripts(createdAt); CREATE INDEX IF NOT EXISTS idx_scripts_approved ON scripts(isApproved); CREATE INDEX IF NOT EXISTS idx_ratings_script ON ratings(scriptId); CREATE INDEX IF NOT EXISTS idx_analytics_script ON script_analytics(scriptId); CREATE INDEX IF NOT EXISTS idx_analytics_created ON script_analytics(createdAt); -- Set up database optimization SET GLOBAL innodb_buffer_pool_size = 268435456; -- 256MB SET GLOBAL max_connections = 200; -- Print initialization complete message SELECT 'ScriptShare database initialization completed!' as message;