Skip to content

Commit 221528f

Browse files
feat(seed): Base data in database
Adding database seed data for quickly validation.
1 parent 5e94ea9 commit 221528f

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

database/02_seed.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- insert users
2+
INSERT INTO users (name, email, phone, birth_date, password_hash)
3+
VALUES
4+
('Alice Silva', 'alice@example.com', '11999999999', '1995-05-10', '$2b$12$hashfakealice'),
5+
('Bruno Costa', 'bruno@example.com', '21988888888', '1990-07-22', '$2b$12$hashfakebruno'),
6+
('Carla Mendes', 'carla@example.com', '31977777777', '1988-11-03', '$2b$12$hashfakecarla');
7+
8+
-- insert projects
9+
INSERT INTO projects (user_id, title, description)
10+
VALUES
11+
(1, 'Projeto Casa', 'Organizar tarefas domésticas'),
12+
(1, 'Trabalho', 'Atividades da empresa'),
13+
(2, 'Viagem', 'Planejamento da viagem para 2025');
14+
15+
-- insert tasks
16+
INSERT INTO tasks (user_id, project_id, title, description, due_date, reminder, completed)
17+
VALUES
18+
(1, 1, 'Lavar roupa', 'Separar roupas coloridas e brancas', '2025-09-30 18:00:00', TRUE, FALSE),
19+
(1, 1, 'Comprar mantimentos', 'Ir ao mercado comprar frutas e verduras', '2025-09-25 20:00:00', FALSE, FALSE),
20+
(1, 2, 'Revisar relatório', 'Revisão do relatório trimestral', '2025-09-28 10:00:00', TRUE, FALSE),
21+
(2, 3, 'Reservar hotel', 'Hotel em Florianópolis', '2025-10-10 12:00:00', TRUE, FALSE),
22+
(2, 3, 'Comprar passagens', 'Passagens aéreas ida e volta', '2025-09-27 15:00:00', FALSE, TRUE),
23+
(3, NULL, 'Estudar Python', 'Praticar FastAPI para o backend', '2025-09-26 19:00:00', FALSE, FALSE);

docker/MySQL/dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ ENV MYSQL_ROOT_PASSWORD=root_pass
88

99
# Copy schema SQL file to the container's initialization directory
1010
COPY ../../database/database_schema.sql /docker-entrypoint-initdb.d/01_schema.sql
11+
COPY ../../database/02_seed.sql /docker-entrypoint-initdb.d/02_seed.sql

docs/en/api_project_architecture_en.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ It includes schemas, routes, modules, and utility functions to provide a clear s
1717
- [routes](#routes)
1818
- [schemas](#schemas)
1919
- [utils](#utils)
20+
- [database](#database)
2021
- [main.py](#mainpy)
2122

2223
---
@@ -104,6 +105,15 @@ Contains helper functions and utility scripts.
104105
- **`utils.py`** → General utility functions used across the project.
105106
- **`__init__.py`** → Initializes the utils package.
106107

108+
---
109+
110+
### `database`
111+
Contains SQL files used to initialize and populate the MySQL database.
112+
113+
- **`database_schema.sql`** → Defines the database schema, including tables, indexes, and relationships.
114+
- **`02_seed.sql`** → Provides initial test data (users, projects, and tasks) to quickly validate the API endpoints.
115+
116+
107117
---
108118

109119
### `main.py`

docs/en/mysql_docker_documentation_en.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ The file [`docker/MySQL/dockerfile`](../../docker/MySQL/dockerfile) is responsib
3232
MySQL automatically executes all `.sql` files inside `/docker-entrypoint-initdb.d` on the container’s first startup.
3333
Thus, the schema defined in [`database/database_schema.sql`](../../database/database_schema.sql) is loaded automatically.
3434

35+
4. **Copy the seed**
36+
```dockerfile
37+
COPY ../../database/02_seed.sql /docker-entrypoint-initdb.d/02_seed.sql
38+
```
39+
Seed of data for quickly validation of database creation.
40+
3541
---
3642

3743
## How to Run the Database

docs/pt-br/api_project_architecture.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Inclui schemas, rotas, módulos e funções utilitárias para garantir uma clara
1717
- [routes](#routes)
1818
- [schemas](#schemas)
1919
- [utils](#utils)
20+
- [database](#database)
2021
- [main.py](#mainpy)
2122

2223
---
@@ -104,6 +105,12 @@ Contém funções auxiliares e scripts utilitários.
104105
- **`utils.py`** → Funções gerais utilizadas em diferentes partes do projeto.
105106
- **`__init__.py`** → Inicializa o pacote de utilitários.
106107

108+
### `database`
109+
Contém arquivos SQL usados para inicializar e popular o banco de dados MySQL.
110+
111+
- **`database_schema.sql`** → Define o schema do banco de dados, incluindo tabelas, índices e relacionamentos.
112+
- **`02_seed.sql`** → Fornece dados iniciais de teste (usuários, projetos e tarefas) para validar rapidamente os endpoints da API.
113+
107114
---
108115

109116
### `main.py`

docs/pt-br/mysql_docker_documentation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ O arquivo [`docker/MySQL/dockerfile`](../../docker/MySQL/dockerfile) é respons
3232
O MySQL executa automaticamente todos os arquivos `.sql` que estiverem na pasta `/docker-entrypoint-initdb.d` na primeira inicialização do container.
3333
Assim, o schema definido em [`database/database_schema.sql`](../../database/database_schema.sql) é carregado automaticamente.
3434

35+
4. **Copiar o seed**
36+
```dockerfile
37+
COPY ../../database/02_seed.sql /docker-entrypoint-initdb.d/02_seed.sql
38+
```
39+
40+
Arquivo de seed de dados para validação rápida da criação do banco de dados.
41+
3542
---
3643

3744
## Como rodar o banco de dados

0 commit comments

Comments
 (0)