Skip to content

Commit 9b57cd2

Browse files
fix(management,migrations): automatically create migrations for new projects
- Add database table existence check in makemigrations command - Automatically create migrations for new projects with missing tables - Fix empty migration detection logic to properly identify SQL-based migrations - Add automatic database initialization before migration checks - Improve migration workflow for new project setup
1 parent b41abca commit 9b57cd2

30 files changed

+627
-60
lines changed

CHANGELOG_TEMPLATES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@
110110

111111
*Дата выпуска: Декабрь 2024*
112112
*Версия Cotlette: 0.1.0+*
113+

EXAMPLES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,4 @@ volumes:
666666
- Тесты
667667
668668
Используйте эти примеры как отправную точку для создания собственных проектов на базе Cotlette.
669+

README_TEMPLATES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,4 @@ python manage.py collectstatic
275275
## Лицензия
276276

277277
Шаблоны распространяются под той же лицензией, что и фреймворк Cotlette.
278+

src/cotlette/conf/project_template/README.md-tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ python manage.py test
142142
## Поддержка
143143

144144
Для получения поддержки обратитесь к документации Cotlette или создайте issue в репозитории.
145+

src/cotlette/conf/project_template/alembic.ini-tpl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ prepend_sys_path = .
3434
# sourceless = false
3535

3636
# version number format
37-
version_num_format = %04d
37+
version_num_format = {0:04d}
3838

3939
# version path separator; As mentioned above, this is the character used to split
4040
# version_locations. The default within new alembic.ini files is "os", which uses
@@ -73,7 +73,7 @@ sqlalchemy.url = sqlite:///db.sqlite3
7373
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
7474
# hooks = ruff
7575
# ruff.type = exec
76-
# ruff.executable = %(here)s/.venv/bin/ruff
76+
# ruff.executable = {here}/.venv/bin/ruff
7777
# ruff.options = --fix REVISION_SCRIPT_FILENAME
7878

7979
# Logging configuration
@@ -87,17 +87,17 @@ keys = console
8787
keys = generic
8888

8989
[logger_root]
90-
level = WARN
90+
level = ERROR
9191
handlers = console
9292
qualname =
9393

9494
[logger_sqlalchemy]
95-
level = WARN
95+
level = ERROR
9696
handlers =
9797
qualname = sqlalchemy.engine
9898

9999
[logger_alembic]
100-
level = INFO
100+
level = ERROR
101101
handlers =
102102
qualname = alembic
103103

@@ -108,5 +108,5 @@ level = NOTSET
108108
formatter = generic
109109

110110
[formatter_generic]
111-
format = %(levelname)-5.5s [%(name)s] %(message)s
112-
datefmt = %H:%M:%S
111+
format = {levelname}-5.5s [{name}] {message}
112+
datefmt = {H}:{M}:{S}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Приложение home
22

33
default_app_config = 'apps.home.apps.AppConfig'
4+
5+
# Экспорт роутера для автоматического подключения
6+
from .urls import router

src/cotlette/conf/project_template/apps/home/admin.py-tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ class HomePageAdmin(admin.ModelAdmin):
2121
'classes': ('collapse',)
2222
}),
2323
)
24+

src/cotlette/conf/project_template/apps/home/api.py-tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ async def update_home_page(request: Request):
5151
"status": "error",
5252
"message": str(e)
5353
}
54+

src/cotlette/conf/project_template/apps/home/apps.py-tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ class AppConfig(AppConfig):
88
def ready(self):
99
# Импорт сигналов и других компонентов при инициализации
1010
pass
11+
12+
@property
13+
def router(self):
14+
"""Возвращает роутер приложения"""
15+
from .urls import router
16+
return router

src/cotlette/conf/project_template/apps/home/controlles.py-tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from cotlette.shortcuts import render
1+
from cotlette.shortcuts import render_template
22
from .models import HomePage
33

44
class HomeController:
@@ -20,20 +20,20 @@ class HomeController:
2020
'home_page': None
2121
}
2222

23-
return render(request, 'home/home.html', context)
23+
return render_template(request, 'home/home.html', context)
2424

2525
async def about(self, request):
2626
"""Страница 'О нас'"""
2727
context = {
2828
'title': 'О нас',
2929
'content': 'Информация о вашем проекте.'
3030
}
31-
return render(request, 'home/about.html', context)
31+
return render_template(request, 'home/about.html', context)
3232

3333
async def contact(self, request):
3434
"""Страница контактов"""
3535
context = {
3636
'title': 'Контакты',
3737
'content': 'Свяжитесь с нами.'
3838
}
39-
return render(request, 'home/contact.html', context)
39+
return render_template(request, 'home/contact.html', context)

0 commit comments

Comments
 (0)