Skip to content

Commit

Permalink
Don't expect paths can be any longer than 255 characters
Browse files Browse the repository at this point in the history
We can reasonably assume that file paths can not be any longer
than 255 characters since that's the ceiling in most established
filesystems [1].

This fixes an issue with the MySQL implementation so we don't go
over the indexed field limit of 767 bytes.

[1]: https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

Change-Id: I57d71c26aa1db7b31c6ef36989464c460aab70e1
  • Loading branch information
David Moreau-Simard committed Dec 5, 2016
1 parent da298a8 commit dd159df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ara/db/versions/001_initial_revision.py
Expand Up @@ -23,7 +23,7 @@ def upgrade():
)
op.create_table('playbooks',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('path', sa.Text(), nullable=True),
sa.Column('path', sa.String(255), nullable=True),
sa.Column('time_start', sa.DateTime(), nullable=True),
sa.Column('time_end', sa.DateTime(), nullable=True),
sa.Column('complete', sa.Boolean(), nullable=True),
Expand All @@ -32,7 +32,7 @@ def upgrade():
op.create_table('files',
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('playbook_id', sa.String(length=36), nullable=True),
sa.Column('path', sa.String(length=3000), nullable=True),
sa.Column('path', sa.String(length=255), nullable=True),
sa.Column('content_id', sa.String(length=40), nullable=True),
sa.Column('is_playbook', sa.Boolean(), nullable=True),
sa.ForeignKeyConstraint(['content_id'], ['file_contents.id'], ),
Expand Down
4 changes: 2 additions & 2 deletions ara/models.py
Expand Up @@ -137,7 +137,7 @@ class Playbook(db.Model, TimedEntity):
__tablename__ = 'playbooks'

id = std_pkey()
path = db.Column(db.Text)
path = db.Column(db.String(255))
data = one_to_many('Data', backref='playbook')
files = one_to_many('File', backref='playbook')
plays = one_to_many('Play', backref='playbook')
Expand Down Expand Up @@ -172,7 +172,7 @@ class File(db.Model):
# limited to a maximum key length of 3072 bytes. This
# restrictions stems from the fact that we are using this column in
# a UNIQUE constraint.
path = db.Column(db.String(3000))
path = db.Column(db.String(255))
content = many_to_one('FileContent', backref='files')
content_id = db.Column(db.String(40),
db.ForeignKey('file_contents.id'))
Expand Down

0 comments on commit dd159df

Please sign in to comment.