Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a deleted_at column in Vm table of db #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Added a deleted_at field in Vm table

Revision ID: 16740cdbdd7c
Revises:
Create Date: 2018-03-15 11:35:59.559663

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '16740cdbdd7c'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('vm', sa.Column('deleted_at', sa.DateTime(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('vm', 'deleted_at')
# ### end Alembic commands ###
62 changes: 0 additions & 62 deletions migrations/versions/45b003a9a66f_.py

This file was deleted.

2 changes: 2 additions & 0 deletions softserve/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pyrax
import re
import logging
from datetime import datetime
from novaclient.exceptions import NotFound
from functools import wraps
from flask import jsonify
Expand Down Expand Up @@ -82,5 +83,6 @@ def delete_node(vm_name):
except NotFound:
logging.exception('Server not found')
vm.state = 'DELETED'
vm.deleted_at = datetime.now
db.session.add(vm)
db.session.commit()
1 change: 1 addition & 0 deletions softserve/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Vm(db.Model):
vm_name = db.Column(db.String(100), unique=False, nullable=False)
details_id = db.Column(db.Integer, db.ForeignKey('node_request.id'))
created_at = db.Column(db.DateTime, default=datetime.now)
deleted_at = db.Column(db.DateTime)
state = db.Column(db.String(10))

def __init__(self, ip_address, vm_name, state):
Expand Down