Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-backend / pithos / backends / lib / sqlalchemy / alembic / versions / 3dd56e750a3_fix_latest_version.py @ 329b8349

History | View | Annotate | Download (878 Bytes)

1
"""Fix latest_version
2

3
Revision ID: 3dd56e750a3
4
Revises: 230f8ce9c90f
5
Create Date: 2012-07-19 14:36:24.242310
6

7
"""
8

    
9
# revision identifiers, used by Alembic.
10
revision = '3dd56e750a3'
11
down_revision = '230f8ce9c90f'
12

    
13
from alembic import op
14
import sqlalchemy as sa
15
from sqlalchemy.sql import table, column
16
from sqlalchemy.sql.expression import desc
17

    
18

    
19
def upgrade():
20
    n = table('nodes',
21
              column('node', sa.Integer),
22
              column('latest_version', sa.Integer)
23
              )
24
    v = table('versions',
25
              column('node', sa.Integer),
26
              column('mtime', sa.Integer),
27
              column('serial', sa.Integer),
28
              )
29

    
30
    s = sa.select([v.c.serial]).where(
31
        n.c.node == v.c.node).order_by(desc(v.c.mtime)).limit(1)
32
    op.execute(
33
        n.update().
34
        values({'latest_version': s})
35
    )
36

    
37

    
38
def downgrade():
39
    pass