-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodejar.sql
More file actions
89 lines (81 loc) · 3.47 KB
/
codejar.sql
File metadata and controls
89 lines (81 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
-- Database: codejar
CREATE DATABASE IF NOT EXISTS codejar CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE codejar;
-- Users table
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`bio` text DEFAULT NULL,
`profile_image` varchar(255) DEFAULT 'default-avatar.jpg',
`website` varchar(255) DEFAULT NULL,
`github` varchar(50) DEFAULT NULL,
`twitter` varchar(50) DEFAULT NULL,
`role` enum('user','admin') DEFAULT 'user',
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Uploads table
CREATE TABLE `uploads` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`title` varchar(100) NOT NULL,
`description` text DEFAULT NULL,
`file_path` varchar(255) NOT NULL,
`poster_path` varchar(255) DEFAULT NULL,
`file_size` int(11) DEFAULT NULL,
`download_count` int(11) DEFAULT 0,
`is_approved` tinyint(1) DEFAULT 1,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `uploads_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Widgets table
CREATE TABLE `widgets` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`title` varchar(100) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`description` text DEFAULT NULL,
`payment_method` enum('khalti','esewa','both') DEFAULT 'both',
`is_active` tinyint(1) DEFAULT 1,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `widgets_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Donations table
CREATE TABLE `donations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`donor_id` int(11) DEFAULT NULL,
`recipient_id` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL,
`message` text DEFAULT NULL,
`payment_method` enum('khalti','esewa') NOT NULL,
`transaction_id` varchar(100) DEFAULT NULL,
`status` enum('pending','completed','failed') DEFAULT 'pending',
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`completed_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `donor_id` (`donor_id`),
KEY `recipient_id` (`recipient_id`),
CONSTRAINT `donations_ibfk_1` FOREIGN KEY (`donor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
CONSTRAINT `donations_ibfk_2` FOREIGN KEY (`recipient_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Sessions table
CREATE TABLE `sessions` (
`session_id` varchar(128) NOT NULL,
`expires` int(11) unsigned NOT NULL,
`data` text DEFAULT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Default admin user (password: admin123)
INSERT INTO `users` (`username`, `email`, `password`, `name`, `role`)
VALUES ('admin', 'admin@codejar.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Admin User', 'admin');