Skip to content

Commit 46bb91d

Browse files
auto db seed
1 parent 2a5d7a5 commit 46bb91d

File tree

3 files changed

+66
-9
lines changed

3 files changed

+66
-9
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ jobs:
3434
cd /root/ourawork
3535
docker compose down
3636
docker compose up -d
37+
# Run DB seed script
38+
bash db/seed_database.sh

README.md

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,20 @@ This web application facilitates connections between restaurants looking to prom
2626
### Getting Started
2727

2828
1. Clone the repository:
29+
2930
```
3031
git clone <repository-url>
3132
cd food-influencer-marketplace
3233
```
3334

3435
2. Start the Docker containers:
36+
3537
```
3638
docker-compose up -d
3739
```
3840

3941
3. Initialize the database:
42+
4043
```
4144
docker-compose exec db mysql -umktuser -pmkpass marketplace < schema.sql
4245
```
@@ -88,11 +91,12 @@ This web application facilitates connections between restaurants looking to prom
8891
The application uses the following database tables:
8992

9093
### users
94+
9195
- `id` - Primary key
9296
- `name` - User's full name
9397
- `email` - User's email (unique)
9498
- `password` - Hashed password
95-
- `role` - Either 'restaurant' or 'influencer'
99+
- `role` - Either 'restaurant', 'influencer', or 'admin'
96100
- `bio` - User's bio/description
97101
- `profile_image` - Path to profile photo
98102
- `social_links` - JSON containing social media links
@@ -101,6 +105,7 @@ The application uses the following database tables:
101105
- `created_at` - Account creation timestamp
102106

103107
### gigs
108+
104109
- `id` - Primary key
105110
- `restaurant_id` - Foreign key to users table
106111
- `title` - Gig title
@@ -110,6 +115,7 @@ The application uses the following database tables:
110115
- `created_at` - Creation timestamp
111116

112117
### applications
118+
113119
- `id` - Primary key
114120
- `gig_id` - Foreign key to gigs table
115121
- `influencer_id` - Foreign key to users table
@@ -118,6 +124,7 @@ The application uses the following database tables:
118124
- `applied_at` - Application timestamp
119125

120126
### instagram_tokens
127+
121128
- `id` - Primary key
122129
- `user_id` - Foreign key to users table
123130
- `account_name` - Friendly name for the Instagram account
@@ -128,6 +135,7 @@ The application uses the following database tables:
128135
- `created_at` - Creation timestamp
129136

130137
### instagram_posts
138+
131139
- `id` - Primary key
132140
- `influencer_id` - Foreign key to users table
133141
- `token_id` - Foreign key to instagram_tokens table
@@ -143,22 +151,26 @@ The application uses the following database tables:
143151
## Key Features
144152

145153
### Authentication & Authorization
154+
146155
- User registration and login
147156
- Role-based access control (restaurant vs. influencer)
148157
- Session management
149158

150159
### Profiles
160+
151161
- Enhanced user profiles with role-specific fields
152162
- Profile image upload
153163
- Social media integration
154164
- Editable details
155165

156166
### For Restaurants
167+
157168
- Post gigs with details
158169
- Review and respond to applications
159170
- Manage multiple gigs
160171

161172
### For Influencers
173+
162174
- Browse available gigs
163175
- Apply to gigs with personalized messages
164176
- Track application status
@@ -184,19 +196,22 @@ The platform includes comprehensive Instagram integration for influencers, allow
184196
2. Create a new app with the Instagram Basic Display product
185197

186198
3. Configure your app:
199+
187200
- Add the Instagram Basic Display product
188201
- Configure Valid OAuth Redirect URIs with your domain + `/instagram_auth.php`
189202
- Add your domain to App Domains
190203
- Note your App ID and App Secret
191204

192205
4. Update `html/includes/instagram_config.php`:
206+
193207
```php
194208
define('INSTAGRAM_APP_ID', 'your-app-id');
195209
define('INSTAGRAM_APP_SECRET', 'your-app-secret');
196210
define('INSTAGRAM_REDIRECT_URI', 'https://your-domain.com/instagram_auth.php');
197211
```
198212

199213
5. Configure the Instagram webhook (optional for real-time updates):
214+
200215
- Set up a webhook in the Meta Developer Dashboard
201216
- Point it to: `https://your-domain.com/api/instagram_webhook.php`
202217
- Use the verify token defined in `html/instagram_webhook.php`: `food_influencer_webhook_token`
@@ -229,18 +244,19 @@ The latest update adds support for managing multiple Instagram accounts per user
229244

230245
1. Create a new PHP file in the `html` directory
231246
2. Include the required files at the top:
247+
232248
```php
233249
<?php
234250
require_once 'includes/db_connect.php';
235-
251+
236252
// Add page-specific logic here
237-
253+
238254
// Include header (after potential redirects)
239255
require_once 'includes/header.php';
240256
?>
241-
257+
242258
<!-- HTML content here -->
243-
259+
244260
<?php require_once 'includes/footer.php'; ?>
245261
```
246262

@@ -310,11 +326,11 @@ if (!empty($_FILES['file']['name'])) {
310326
$file_extension = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
311327
$new_filename = "file_" . time() . "." . $file_extension;
312328
$target_file = $target_dir . $new_filename;
313-
329+
314330
// Validate file
315331
$allowed_types = ['jpg', 'jpeg', 'png', 'pdf'];
316332
$max_size = 5 * 1024 * 1024; // 5MB
317-
333+
318334
if ($_FILES["file"]["size"] > $max_size) {
319335
$error = "File is too large";
320336
} elseif (!in_array(strtolower($file_extension), $allowed_types)) {
@@ -341,13 +357,15 @@ if (!empty($_FILES['file']['name'])) {
341357
### PHP Configuration
342358

343359
Key PHP settings are in `html/php.ini`:
360+
344361
- upload_max_filesize = 10M
345362
- post_max_size = 20M
346363
- memory_limit = 128M
347364

348365
### Nginx Configuration
349366

350367
Key Nginx settings in `nginx.conf`:
368+
351369
- client_max_body_size = 20M
352370
- Various MIME type settings
353371

@@ -356,6 +374,7 @@ Key Nginx settings in `nginx.conf`:
356374
### File Upload Issues
357375

358376
If experiencing "413 Request Entity Too Large" errors:
377+
359378
- Check if your file exceeds the 10MB limit
360379
- Verify Nginx configuration has proper client_max_body_size value
361380
- Ensure PHP settings for upload_max_filesize and post_max_size are correct
@@ -364,13 +383,16 @@ If experiencing "413 Request Entity Too Large" errors:
364383
### Database Connection Issues
365384

366385
If experiencing database connection problems:
386+
367387
- Verify database credentials in db_connect.php
368388
- Check if the database container is running
369389
- Ensure the schema has been imported
390+
- **If you get an error about the 'role' column not accepting 'admin', see the Seeding section above for how to alter the table.**
370391

371392
### Instagram Integration Issues
372393

373394
If experiencing Instagram connection problems:
395+
374396
- **"Session Invalid" Error**: Clear cookies, try incognito mode, or reconnect the account
375397
- **"Invalid Redirect URI" Error**: Ensure your redirect URI in the code exactly matches what's in the Meta Developer Dashboard
376398
- **Database Column Errors**: The system will automatically update the database schema, but you can manually run the table creation from `instagram_config.php`
@@ -386,4 +408,37 @@ If experiencing Instagram connection problems:
386408

387409
## License
388410

389-
[Your license information here]
411+
[Your license information here]
412+
413+
### Seeding the Database
414+
415+
To seed the database with initial data (including the admin user), use the provided script:
416+
417+
```sh
418+
bash db/seed_database.sh
419+
```
420+
421+
This will:
422+
423+
- Apply the schema
424+
- Seed users, gigs, and other data
425+
- Set up the admin user
426+
427+
#### Admin Credentials (default after seeding):
428+
429+
- **Email:** `[email protected]`
430+
- **Password:** `password123`
431+
432+
#### If you see an error like:
433+
434+
```
435+
ERROR 1265 (01000): Data truncated for column 'role' at row 1
436+
```
437+
438+
This means the `role` column in your `users` table does not yet allow the value `'admin'`. To fix this, run:
439+
440+
```sql
441+
ALTER TABLE users MODIFY role ENUM('restaurant', 'influencer', 'admin') NOT NULL;
442+
```
443+
444+
Then re-run the seed script or the admin setup SQL.

db/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS users (
33
name VARCHAR(100) NOT NULL,
44
email VARCHAR(100) NOT NULL UNIQUE,
55
password CHAR(60) NOT NULL,
6-
role ENUM('restaurant','influencer') NOT NULL,
6+
role ENUM('restaurant', 'influencer', 'admin') NOT NULL,
77
bio TEXT,
88
profile_image VARCHAR(255),
99
social_links JSON,

0 commit comments

Comments
 (0)