-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Urls table and functions (#6)
- Loading branch information
Showing
8 changed files
with
308 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/synack/db/alembic/versions/0c1ac7be711c_added_url_table_deleted_url_from_port_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Added Url table/Deleted url from Port table | ||
Revision ID: 0c1ac7be711c | ||
Revises: deb7dd07212c | ||
Create Date: 2022-06-15 03:14:49.327185 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '0c1ac7be711c' | ||
down_revision = 'deb7dd07212c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table('urls', | ||
sa.Column('id', sa.Integer, primary_key=True), | ||
sa.Column('ip', sa.Integer, sa.ForeignKey('ips.id')), | ||
sa.Column('url', sa.VARCHAR(1024), server_default=''), | ||
sa.Column('screenshot_url', sa.VARCHAR(1024), server_default='')) | ||
with op.batch_alter_table('ports') as batch_op: | ||
batch_op.drop_column('url') | ||
batch_op.drop_column('screenshot_url') | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('urls') | ||
with op.batch_alter_table('ports') as batch_op: | ||
batch_op.add_column(sa.Column('url', sa.VARCHAR(200), server_default='')) | ||
batch_op.add_column(sa.Column('screenshot_url', sa.VARCHAR(1000), server_default='')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
from .ip import IP | ||
from .organization import Organization | ||
from .port import Port | ||
from .url import Url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""db/model/url.py | ||
Database Model for the Url item | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy.orm import declarative_base | ||
from .ip import IP | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Url(Base): | ||
__tablename__ = 'urls' | ||
id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) | ||
ip = sa.Column(sa.Integer, sa.ForeignKey(IP.id)) | ||
url = sa.Column(sa.VARCHAR(1024), default="") | ||
screenshot_url = sa.Column(sa.VARCHAR(1024), default="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.