feat: restaura o projeto original do clube67.com (Next.js + Express API + MySQL + Redis) livre de gambiarras e dockerizado
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
import { Knex } from 'knex';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
export async function seed(knex: Knex): Promise<void> {
|
||||
// ── Super Admin ──
|
||||
const passwordHash = await bcrypt.hash('Rc362514', 12);
|
||||
const [existingAdmin] = await knex('users').where('email', 'ruibto@gmail.com');
|
||||
if (!existingAdmin) {
|
||||
await knex('users').insert({
|
||||
name: 'Super Admin',
|
||||
email: 'ruibto@gmail.com',
|
||||
password_hash: passwordHash,
|
||||
role: 'super_admin',
|
||||
status: 'active',
|
||||
email_verified: true,
|
||||
});
|
||||
}
|
||||
|
||||
// ── Categories ──
|
||||
const categories = [
|
||||
{ name: 'Gastronomia', slug: 'gastronomia', icon: '🍽️', color: '#FF6B35' },
|
||||
{ name: 'Saúde', slug: 'saude', icon: '🏥', color: '#4CAF50' },
|
||||
{ name: 'Educação', slug: 'educacao', icon: '📚', color: '#2196F3' },
|
||||
{ name: 'Lazer', slug: 'lazer', icon: '🎭', color: '#9C27B0' },
|
||||
{ name: 'Esportes', slug: 'esportes', icon: '⚽', color: '#FF9800' },
|
||||
{ name: 'Compras', slug: 'compras', icon: '🛍️', color: '#E91E63' },
|
||||
{ name: 'Serviços', slug: 'servicos', icon: '🔧', color: '#607D8B' },
|
||||
{ name: 'Viagens', slug: 'viagens', icon: '✈️', color: '#00BCD4' },
|
||||
{ name: 'Beleza & Estética', slug: 'beleza-estetica', icon: '💅', color: '#F06292' },
|
||||
{ name: 'Odontologia', slug: 'odontologia', icon: '🦷', color: '#26A69A' },
|
||||
{ name: 'Nutrição', slug: 'nutricao', icon: '🥗', color: '#8BC34A' },
|
||||
{ name: 'Farmácia', slug: 'farmacia', icon: '💊', color: '#EF5350' },
|
||||
];
|
||||
for (const cat of categories) {
|
||||
const exists = await knex('categories').where('slug', cat.slug).first();
|
||||
if (!exists) await knex('categories').insert(cat);
|
||||
}
|
||||
|
||||
// ── Partners ──
|
||||
const superAdmin = await knex('users').where('email', 'ruibto@gmail.com').first();
|
||||
const partners = [
|
||||
{
|
||||
company_name: 'Escola Coração de Maria',
|
||||
slug: 'coracaodemaria',
|
||||
cnpj: '11.222.333/0001-44',
|
||||
phone: '(67) 3333-1111',
|
||||
address_street: 'Rua das Flores', address_number: '123',
|
||||
address_neighborhood: 'Centro', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-001',
|
||||
type: 'Escola', monthly_goal: 50, status: 'active',
|
||||
gradient_from: '#3B82F6', gradient_to: '#1D4ED8',
|
||||
icon: '🏫', description: 'Instituição de ensino fundamental e médio.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
{
|
||||
company_name: 'Drogasil Filial Centro',
|
||||
slug: 'drogasilcentro',
|
||||
cnpj: '44.555.666/0001-77',
|
||||
phone: '(67) 3333-2222',
|
||||
address_street: 'Avenida Principal', address_number: '456',
|
||||
address_neighborhood: 'Tiradentes', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-002',
|
||||
type: 'Farmácia', monthly_goal: 75, status: 'active',
|
||||
gradient_from: '#EF4444', gradient_to: '#B91C1C',
|
||||
icon: '⚕️', description: 'Rede de farmácias com ampla variedade.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
{
|
||||
company_name: 'SmartFit Unidade Centro',
|
||||
slug: 'smartfitcentro',
|
||||
cnpj: null,
|
||||
phone: '(67) 3333-3333',
|
||||
address_street: 'Travessa Esportiva', address_number: '789',
|
||||
address_neighborhood: 'Aero Rancho', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-003',
|
||||
type: 'Academia', monthly_goal: 100, status: 'active',
|
||||
gradient_from: '#EAB308', gradient_to: '#F97316',
|
||||
icon: '🏋️', description: 'Academia com equipamentos modernos.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
{
|
||||
company_name: 'Consultt Clinic',
|
||||
slug: 'consulttclinic',
|
||||
cnpj: null,
|
||||
phone: '(67) 9999-0000',
|
||||
address_street: 'Rua Odonto', address_number: '100',
|
||||
address_neighborhood: 'Centro', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-100',
|
||||
type: 'Odontologia', monthly_goal: 30, status: 'active',
|
||||
gradient_from: '#06B6D4', gradient_to: '#3B82F6',
|
||||
icon: '🦷', description: 'Clínica odontológica de referência.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
{
|
||||
company_name: 'Escola de Música Som do Coração',
|
||||
slug: 'somdocoracao',
|
||||
cnpj: null,
|
||||
phone: '(67) 9999-1112',
|
||||
address_street: 'Rua da Harmonia', address_number: '200',
|
||||
address_neighborhood: 'Centro', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-200',
|
||||
type: 'Curso', monthly_goal: 20, status: 'active',
|
||||
gradient_from: '#A855F7', gradient_to: '#6366F1',
|
||||
icon: '🎵', description: 'Aulas de música para todas as idades.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
{
|
||||
company_name: 'Ótica Central',
|
||||
slug: 'oticacentral',
|
||||
cnpj: null,
|
||||
phone: '(67) 9999-4444',
|
||||
address_street: 'Avenida da Visão', address_number: '300',
|
||||
address_neighborhood: 'Tiradentes', address_city: 'Campo Grande',
|
||||
address_state: 'MS', address_zip: '79000-300',
|
||||
type: 'Ótica', monthly_goal: 40, status: 'active',
|
||||
gradient_from: '#14B8A6', gradient_to: '#22C55E',
|
||||
icon: '👓', description: 'Soluções para saúde visual.',
|
||||
owner_user_id: superAdmin?.id,
|
||||
},
|
||||
];
|
||||
for (const p of partners) {
|
||||
const exists = await knex('partners').where('slug', p.slug).first();
|
||||
if (!exists) await knex('partners').insert(p);
|
||||
}
|
||||
|
||||
// ── Benefits ──
|
||||
const consultt = await knex('partners').where('slug', 'consulttclinic').first();
|
||||
const som = await knex('partners').where('slug', 'somdocoracao').first();
|
||||
const otica = await knex('partners').where('slug', 'oticacentral').first();
|
||||
const catSaude = await knex('categories').where('slug', 'saude').first();
|
||||
const catEducacao = await knex('categories').where('slug', 'educacao').first();
|
||||
const catOdonto = await knex('categories').where('slug', 'odontologia').first();
|
||||
|
||||
const benefits = [
|
||||
{
|
||||
partner_id: consultt?.id,
|
||||
category_id: catOdonto?.id,
|
||||
title: 'Benefício Saúde Bucal',
|
||||
description: 'Cuidado odontológico completo com condições especiais para membros.',
|
||||
rules: 'Benefício válido para membros ativos. Descontos não acumulativos.',
|
||||
contact: '(67) 9999-0000',
|
||||
type: 'dental', delivery_type: 'external',
|
||||
active: true, is_global: true, approved_by_admin: true,
|
||||
global_request_status: 'approved', priority: 1,
|
||||
discount_percent: 30, valid_until: '2026-12-31',
|
||||
redemption_type: 'qrcode',
|
||||
},
|
||||
{
|
||||
partner_id: som?.id,
|
||||
category_id: catEducacao?.id,
|
||||
title: 'Aula de Violão Gratuita',
|
||||
description: 'Experimente uma aula de violão com nossos melhores professores.',
|
||||
rules: 'Válido para novos alunos.',
|
||||
contact: '(67) 9999-1112',
|
||||
type: 'education', delivery_type: 'local',
|
||||
active: true, is_global: false, approved_by_admin: true,
|
||||
global_request_status: 'none', priority: 3,
|
||||
discount_percent: 100, valid_until: '2026-06-30',
|
||||
redemption_type: 'coupon',
|
||||
},
|
||||
{
|
||||
partner_id: otica?.id,
|
||||
category_id: catSaude?.id,
|
||||
title: '25% OFF em Armações',
|
||||
description: 'Escolha qualquer armação da loja com desconto exclusivo.',
|
||||
rules: 'Válido para pagamentos à vista.',
|
||||
contact: '(67) 9999-4444',
|
||||
type: 'health', delivery_type: 'external',
|
||||
active: true, is_global: false, approved_by_admin: true,
|
||||
global_request_status: 'none', priority: 3,
|
||||
discount_percent: 25, valid_until: '2026-12-31',
|
||||
redemption_type: 'coupon',
|
||||
},
|
||||
];
|
||||
for (const b of benefits) {
|
||||
if (b.partner_id) {
|
||||
const exists = await knex('benefits').where('title', b.title).first();
|
||||
if (!exists) await knex('benefits').insert(b);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('✅ Seed completed: super_admin + categories + partners + benefits');
|
||||
}
|
||||
Reference in New Issue
Block a user