Merge pull request #30 from psbleep/longer-migration-version-names
Allow longer migration version names
This commit is contained in:
commit
d74e7b5630
@ -17,7 +17,7 @@ from tortoise import (
|
|||||||
from tortoise.fields import Field
|
from tortoise.fields import Field
|
||||||
|
|
||||||
from aerich.ddl import BaseDDL
|
from aerich.ddl import BaseDDL
|
||||||
from aerich.models import Aerich
|
from aerich.models import MAX_VERSION_LENGTH, Aerich
|
||||||
from aerich.utils import get_app_connection
|
from aerich.utils import get_app_connection
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +89,10 @@ class Migrate:
|
|||||||
last_version_num = await cls._get_last_version_num()
|
last_version_num = await cls._get_last_version_num()
|
||||||
if last_version_num is None:
|
if last_version_num is None:
|
||||||
return f"0_{now}_init.json"
|
return f"0_{now}_init.json"
|
||||||
return f"{last_version_num + 1}_{now}_{name}.json"
|
version = f"{last_version_num + 1}_{now}_{name}.json"
|
||||||
|
if len(version) > MAX_VERSION_LENGTH:
|
||||||
|
raise ValueError(f"Version name exceeds maximum length ({MAX_VERSION_LENGTH})")
|
||||||
|
return version
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def _generate_diff_sql(cls, name):
|
async def _generate_diff_sql(cls, name):
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
from tortoise import Model, fields
|
from tortoise import Model, fields
|
||||||
|
|
||||||
|
MAX_VERSION_LENGTH = 255
|
||||||
|
|
||||||
|
|
||||||
class Aerich(Model):
|
class Aerich(Model):
|
||||||
version = fields.CharField(max_length=50)
|
version = fields.CharField(max_length=MAX_VERSION_LENGTH)
|
||||||
app = fields.CharField(max_length=20)
|
app = fields.CharField(max_length=20)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user