diff --git a/.gitignore b/.gitignore index 1fcadf3de..38e143b6a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ jspm_packages # pytest cache .pytest_cache +lib/__pycache__ diff --git a/README.md b/README.md index b598b7784..58158a42c 100644 --- a/README.md +++ b/README.md @@ -1,182 +1,42 @@ -# Phase 3 Mock Code Challenge: Freebie Tracker +# Freebie Tracker -## Learning Goals +## Project Overview -- Write SQLAlchemy migrations. -- Connect between tables using SQLAlchemy relationships. -- Use SQLAlchemy to run CRUD statements in the database. +This project is a Freebie Tracker app designed to help developers keep track of swag (free items) they collect from hackathons and events. The main models are: -*** +- **Company**: Companies that give out freebies. +- **Dev**: Developers who receive freebies. +- **Freebie**: Items given to developers by companies. -## Key Vocab +The relationships are: -- **Schema**: the blueprint of a database. Describes how data relates to other - data in tables, columns, and relationships between them. -- **Persist**: save a schema in a database. -- **Engine**: a Python object that translates SQL to Python and vice-versa. -- **Session**: a Python object that uses an engine to allow us to - programmatically interact with a database. -- **Transaction**: a strategy for executing database statements such that - the group succeeds or fails as a unit. -- **Migration**: the process of moving data from one or more databases to one - or more target databases. - -*** +- A `Company` has many `Freebie`s. +- A `Dev` has many `Freebie`s. +- A `Freebie` belongs to one `Company` and one `Dev`. +- A `Company` and `Dev` have a many-to-many relationship through freebies. -## Introduction -For this assignment, we'll be working with a freebie domain. +### Database Schema -As developers, when you attend hackathons, you'll realize they hand out a lot of -free items (informally called _freebies_, or swag)! Let's make an app for -developers that keeps track of all the freebies they obtain. +View the full database schema here: +[Schema Link](https://dbdiagram.io/d/Code-Challenge-Schema-682d6600b9f7446da371de0f) -We have three models: `Company`, `Dev`, and `Freebie` +--- -For our purposes, a `Company` has many `Freebie`s, a `Dev` has many `Freebie`s, -and a `Freebie` belongs to a `Dev` and to a `Company`. +## Setup Instructions -`Company` - `Dev` is a many to many relationship. +1. **Install dependencies and activate environment** + Run the following commands inside your project directory: -**Note**: You should draw your domain on paper or on a whiteboard _before you -start coding_. Remember to identify a single source of truth for your data. + ```bash + pipenv install + pipenv shell -## Instructions +2. **Run Migrations** + Create and apply migrations to set up the database schema, including the freebies table -To get started, run `pipenv install && pipenv shell` while inside of this -directory. - -Build out all of the methods listed in the deliverables. The methods are listed -in a suggested order, but you can feel free to tackle the ones you think are -easiest. Be careful: some of the later methods rely on earlier ones. - -**Remember!** This mock code challenge does not have tests. You cannot run -`pytest` and you cannot run `learn test`. You'll need to create your own sample -instances so that you can try out your code on your own. Make sure your -relationships and methods work in the console before submitting. - -We've provided you with a tool that you can use to test your code. To use it, -run `python debug.py` from the command line. This will start an `ipdb` session -with your classes defined. You can test out the methods that you write here. You -are also encouraged to use the `seed.py` file to create sample data to test your -models and associations. - -Writing error-free code is more important than completing all of the -deliverables listed- prioritize writing methods that work over writing more -methods that don't work. You should test your code in the console as you write. - -Similarly, messy code that works is better than clean code that doesn't. First, -prioritize getting things working. Then, if there is time at the end, refactor -your code to adhere to best practices. - -**Before you submit!** Save and run your code to verify that it works as you -expect. If you have any methods that are not working yet, feel free to leave -comments describing your progress. - -*** - -## What You Already Have - -The starter code has migrations and models for the initial `Company` and `Dev` -models, and seed data for some `Company`s and `Dev`s. The schema currently looks -like this: - -### companies Table - -| Column | Type | -| ------------- | ------- | -| name | String | -| founding_year | Integer | - -### devs Table - -| Column | Type | -| ------ | ------ | -| name | String | - -You will need to create the migration for the `freebies` table using the -attributes specified in the deliverables below. - -*** - -## Deliverables - -Write the following methods in the classes in the files provided. Feel free to -build out any helper methods if needed. - -Remember: SQLAlchemy gives your classes access to a lot of methods already! -Keep in mind what methods SQLAlchemy gives you access to on each of your -classes when you're approaching the deliverables below. - -### Migrations - -Before working on the rest of the deliverables, you will need to create a -migration for the `freebies` table. - -- A `Freebie` belongs to a `Dev`, and a `Freebie` also belongs to a `Company`. - In your migration, create any columns your `freebies` table will need to - establish these relationships using the right foreign keys. -- The `freebies` table should also have: - - An `item_name` column that stores a string. - - A `value` column that stores an integer. - -After creating the `freebies` table using a migration, use the `seed.py` file to -create instances of your `Freebie` class so you can test your code. - -**After you've set up your `freebies` table**, work on building out the following -deliverables. - -### Relationship Attributes and Methods - -Use SQLAlchemy's `ForeignKey`, `relationship()`, and `backref()` objects to -build relationships between your three models. - -**Note**: The plural of "freebie" is "freebies" and the singular of "freebies" -is "freebie". - -#### Freebie - -- `Freebie.dev` returns the `Dev` instance for this Freebie. -- `Freebie.company` returns the `Company` instance for this Freebie. - -#### Company - -- `Company.freebies` returns a collection of all the freebies for the Company. -- `Company.devs` returns a collection of all the devs who collected freebies - from the company. - -#### Dev - -- `Dev.freebies` returns a collection of all the freebies that the Dev has collected. -- `Dev.companies`returns a collection of all the companies that the Dev has collected - freebies from. - -Use `python debug.py` and check that these methods work before proceeding. For -example, you should be able to retrieve a dev from the database by its -attributes and view their companies with `dev.companies` (based on your seed -data). - -### Aggregate Methods - -#### Freebie - -- `Freebie.print_details()`should return a string formatted as follows: - `{dev name} owns a {freebie item_name} from {company name}`. - -#### Company - -- `Company.give_freebie(dev, item_name, value)` takes a `dev` (an instance of - the `Dev` class), an `item_name` (string), and a `value` as arguments, and - creates a new `Freebie` instance associated with this company and the given - dev. -- Class method `Company.oldest_company()`returns the `Company` instance with - the earliest founding year. - -#### Dev - -- `Dev.received_one(item_name)` accepts an `item_name` (string) and returns - `True` if any of the freebies associated with the dev has that `item_name`, - otherwise returns `False`. -- `Dev.give_away(dev, freebie)` accepts a `Dev` instance and a `Freebie` - instance, changes the freebie's dev to be the given dev; your code should only - make the change if the freebie belongs to the dev who's giving it away +3. **Seed the database** + Use the provided seed.py script to populate the database with sample data: + ```bash + python seed.py + ``` diff --git a/alembic.ini b/alembic.ini new file mode 100644 index 000000000..953863ddd --- /dev/null +++ b/alembic.ini @@ -0,0 +1,105 @@ +# A generic, single database configuration. + +[alembic] +# path to migration scripts +script_location = migrations + +# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s +# Uncomment the line below if you want the files to be prepended with date and time +# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file +# for all available tokens +# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s + +# sys.path path, will be prepended to sys.path if present. +# defaults to the current working directory. +prepend_sys_path = . + +# timezone to use when rendering the date within the migration file +# as well as the filename. +# If specified, requires the python-dateutil library that can be +# installed by adding `alembic[tz]` to the pip requirements +# string value is passed to dateutil.tz.gettz() +# leave blank for localtime +# timezone = + +# max length of characters to apply to the +# "slug" field +# truncate_slug_length = 40 + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + +# set to 'true' to allow .pyc and .pyo files without +# a source .py file to be detected as revisions in the +# versions/ directory +# sourceless = false + +# version location specification; This defaults +# to migrations/versions. When using multiple version +# directories, initial revisions must be specified with --version-path. +# The path separator used here should be the separator specified by "version_path_separator" below. +# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions + +# version path separator; As mentioned above, this is the character used to split +# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep. +# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas. +# Valid values for version_path_separator are: +# +# version_path_separator = : +# version_path_separator = ; +# version_path_separator = space +version_path_separator = os # Use os.pathsep. Default configuration used for new projects. + +# the output encoding used when revision files +# are written from script.py.mako +# output_encoding = utf-8 + +sqlalchemy.url = sqlite:///freebies.db + + +[post_write_hooks] +# post_write_hooks defines scripts or Python functions that are run +# on newly generated revision scripts. See the documentation for further +# detail and examples + +# format using "black" - use the console_scripts runner, against the "black" entrypoint +# hooks = black +# black.type = console_scripts +# black.entrypoint = black +# black.options = -l 79 REVISION_SCRIPT_FILENAME + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/freebies.db b/freebies.db new file mode 100644 index 000000000..735079b11 Binary files /dev/null and b/freebies.db differ diff --git a/lib/__pycache__/models.cpython-38.pyc b/lib/__pycache__/models.cpython-38.pyc new file mode 100644 index 000000000..992c90595 Binary files /dev/null and b/lib/__pycache__/models.cpython-38.pyc differ diff --git a/lib/debug.py b/lib/debug.py index 4f922eb69..98d5219c6 100644 --- a/lib/debug.py +++ b/lib/debug.py @@ -1,9 +1,39 @@ #!/usr/bin/env python3 - from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker -from models import Company, Dev +from models import Company, Dev, Freebie, Base if __name__ == '__main__': engine = create_engine('sqlite:///freebies.db') + Base.metadata.create_all(engine) + Session = sessionmaker(bind=engine) + session = Session() + + # querying data from my db (seed data) + first_company = session.query(Company).first() + first_dev = session.query(Dev).first() + first_freebie = session.query(Freebie).first() + + print("Testing print_details() on first freebie:") + if first_freebie: + print(first_freebie.print_details()) + + print("\nTesting oldest_company():") + oldest = Company.oldest_company(session) + print(oldest) + + print("\nTesting received_one() on first dev with item 'Tshirts':") + if first_dev: + print(first_dev.received_one('Tshirts')) + + # Testing give_away() (transfer first freebie from its current owner to another dev if possible) + second_dev = session.query(Dev).filter(Dev.id != first_dev.id).first() if first_dev else None + if first_dev and second_dev and first_freebie: + print(f"\nBefore give_away: {first_freebie.print_details()}") + success = first_dev.give_away(second_dev, first_freebie) + session.commit() + print("Give away success?", success) + print(f"After give_away: {first_freebie.print_details()}") + import ipdb; ipdb.set_trace() diff --git a/lib/migrations/README b/lib/migrations/README deleted file mode 100644 index 98e4f9c44..000000000 --- a/lib/migrations/README +++ /dev/null @@ -1 +0,0 @@ -Generic single-database configuration. \ No newline at end of file diff --git a/lib/migrations/versions/7a71dbf71c64_create_db.py b/lib/migrations/versions/7a71dbf71c64_create_db.py deleted file mode 100644 index 23e0a655b..000000000 --- a/lib/migrations/versions/7a71dbf71c64_create_db.py +++ /dev/null @@ -1,24 +0,0 @@ -"""create db - -Revision ID: 7a71dbf71c64 -Revises: -Create Date: 2023-03-15 15:05:55.516631 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '7a71dbf71c64' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade() -> None: - pass - - -def downgrade() -> None: - pass diff --git a/lib/models.py b/lib/models.py index 2681bee5a..60c03ee18 100644 --- a/lib/models.py +++ b/lib/models.py @@ -1,29 +1,91 @@ -from sqlalchemy import ForeignKey, Column, Integer, String, MetaData -from sqlalchemy.orm import relationship, backref +from sqlalchemy import ForeignKey, Column, Integer, String, MetaData, Table +from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base convention = { "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s", } metadata = MetaData(naming_convention=convention) - Base = declarative_base(metadata=metadata) +# Junction table for many-to-many between Company and Dev +company_dev = Table( + 'company_dev', + Base.metadata, + Column('company_id', Integer, ForeignKey('companies.id'), primary_key=True), + Column('dev_id', Integer, ForeignKey('devs.id'), primary_key=True) +) + class Company(Base): __tablename__ = 'companies' - id = Column(Integer(), primary_key=True) - name = Column(String()) - founding_year = Column(Integer()) + id = Column(Integer, primary_key=True) + company_name = Column(String, nullable=False) + founding_year = Column(Integer) + + # Relationships + devs = relationship("Dev", secondary="company_dev", back_populates="companies") + freebies = relationship("Freebie", back_populates="company") + + def give_freebie(self, dev, item_name, value): + """Create a new Freebie for a Dev from this Company.""" + new_freebie = Freebie(item_name=item_name, value=value, company=self, dev=dev) + return new_freebie + + @classmethod + def oldest_company(cls, session): + """Return the Company with the earliest founding year.""" + return session.query(cls).order_by(cls.founding_year.asc()).first() def __repr__(self): - return f'' + return f"" + class Dev(Base): __tablename__ = 'devs' - id = Column(Integer(), primary_key=True) - name= Column(String()) + id = Column(Integer, primary_key=True) + dev_name = Column(String, nullable=False) + + # Relationships + companies = relationship("Company", secondary="company_dev", back_populates="devs") + freebies = relationship("Freebie", back_populates="dev") + + #aggregate methods + def received_one(self, item_name): + """Return True if the Dev has received a freebie with the given item name.""" + return any(freebie.item_name == item_name for freebie in self.freebies) + + def give_away(self, other_dev, freebie): + """ + Transfer ownership of a freebie to another Dev, + only if the current Dev owns it. + """ + if freebie in self.freebies: + freebie.dev = other_dev + return True + return False + + def __repr__(self): + return f"" + +class Freebie(Base): + __tablename__ = 'freebies' + + id = Column(Integer, primary_key=True) + value = Column(Integer, nullable=False) + item_name = Column(String, nullable=False) + company_id = Column(Integer, ForeignKey('companies.id'), nullable=False) + dev_id = Column(Integer, ForeignKey('devs.id'), nullable=False) + + # Relationships + company = relationship("Company", back_populates="freebies") + dev = relationship("Dev", back_populates="freebies") + + def print_details(self): + return f"{self.dev.dev_name} owns a {self.item_name} from {self.company.company_name}" def __repr__(self): - return f'' + dev_name = self.dev.dev_name if self.dev else "Unknown Dev" + company_name = self.company.company_name if self.company else "Unknown Company" + return f"" diff --git a/lib/seed.py b/lib/seed.py index b16becbbb..17eedc021 100644 --- a/lib/seed.py +++ b/lib/seed.py @@ -1,3 +1,63 @@ #!/usr/bin/env python3 +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from models import Company, Dev, Freebie -# Script goes here! +from faker import Faker + +import random + +# Connect to Database +if __name__ == '__main__': + engine = create_engine('sqlite:///freebies.db') + Session = sessionmaker(bind=engine) + session = Session() + + fake = Faker() # Instantiating it then using it to generate dummy data + + #dev instance + devs = [] + for _ in range(6): + dev = Dev( + dev_name = fake.name() + ) + devs.append(dev) + session.add_all(devs) + session.commit() + + + #company instance + companies = [] + for _ in range (6): # the _ represents a placeholder for a var we dont need + company = Company( + company_name = fake.company(), + founding_year = random.randint(2010,2020) + ) + companies.append(company) + session.add_all(companies) + session.commit() #save + + # My Junction -> Many to Many table (company_dev table) + for dev in devs: + related_companies = random.sample(companies, random.randint(1,5)) + for company in related_companies: + dev.companies.append(company) + session.commit() + + # freebies has-manys + freebies = [] + item_names = ['Flask', 'Tshirts', 'stickers', 'Notebook', 'Pens','Gadgets'] + for _ in range(10): + freebie = Freebie( + item_name=random.choice(item_names), + value=random.randint(1,10), + company=random.choice(companies), + dev=random.choice(devs) + ) + freebies.append(freebie) + session.add_all(freebies) + session.commit() + + print("Congrats Data Seeded,lol ") + + \ No newline at end of file diff --git a/migrations/README b/migrations/README new file mode 100644 index 000000000..4b801be9d --- /dev/null +++ b/migrations/README @@ -0,0 +1,18 @@ +# Freebie Tracker - Migrations + +## Overview + +This guide explains how to create and manage database migrations for the Freebie Tracker project using **Alembic** with SQLAlchemy. + +Migrations help you version control your database schema changes. When you add or modify tables, columns, or relationships in your models, you create a migration to update the database accordingly. + + + +## Prerequisites to Have + +- You have Alembic installed and configured. +- Your SQLAlchemy models are defined and ready. +- You have a working database connection URL in your Alembic configuration. + + + diff --git a/migrations/__pycache__/env.cpython-38.pyc b/migrations/__pycache__/env.cpython-38.pyc new file mode 100644 index 000000000..4bbfdb47a Binary files /dev/null and b/migrations/__pycache__/env.cpython-38.pyc differ diff --git a/lib/migrations/env.py b/migrations/env.py similarity index 86% rename from lib/migrations/env.py rename to migrations/env.py index c7aab9656..d7f367bb4 100644 --- a/lib/migrations/env.py +++ b/migrations/env.py @@ -5,6 +5,12 @@ from alembic import context +#Fixing path issues +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -16,9 +22,15 @@ # add your model's MetaData object here # for 'autogenerate' support + +# Import your models here / should inherit from the same Base initialization +from lib.models import Dev,Company,Freebie +# Import the base class +from lib.models import Base + # from myapp import mymodel # target_metadata = mymodel.Base.metadata -from models import Base +from lib.models import Base target_metadata = Base.metadata # other values from the config, defined by the needs of env.py, diff --git a/lib/migrations/script.py.mako b/migrations/script.py.mako similarity index 100% rename from lib/migrations/script.py.mako rename to migrations/script.py.mako diff --git a/lib/migrations/versions/5f72c58bf48c_create_companies_devs.py b/migrations/versions/08030acbb158_initial_migration.py similarity index 73% rename from lib/migrations/versions/5f72c58bf48c_create_companies_devs.py rename to migrations/versions/08030acbb158_initial_migration.py index c191bb2f9..7d8e68cdb 100644 --- a/lib/migrations/versions/5f72c58bf48c_create_companies_devs.py +++ b/migrations/versions/08030acbb158_initial_migration.py @@ -1,8 +1,8 @@ -"""create companies, devs +"""Initial Migration -Revision ID: 5f72c58bf48c -Revises: 7a71dbf71c64 -Create Date: 2023-03-15 15:06:20.944586 +Revision ID: 08030acbb158 +Revises: +Create Date: 2025-05-25 10:13:29.069434 """ from alembic import op @@ -10,8 +10,8 @@ # revision identifiers, used by Alembic. -revision = '5f72c58bf48c' -down_revision = '7a71dbf71c64' +revision = '08030acbb158' +down_revision = None branch_labels = None depends_on = None @@ -20,13 +20,13 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('companies', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=True), + sa.Column('company_name', sa.String(), nullable=True), sa.Column('founding_year', sa.Integer(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_table('devs', sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=True), + sa.Column('dev_name', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ### diff --git a/migrations/versions/1a523e61dad7_added_a_freebie_and_junction_table.py b/migrations/versions/1a523e61dad7_added_a_freebie_and_junction_table.py new file mode 100644 index 000000000..520430306 --- /dev/null +++ b/migrations/versions/1a523e61dad7_added_a_freebie_and_junction_table.py @@ -0,0 +1,45 @@ +"""Added a Freebie and Junction Table + +Revision ID: 1a523e61dad7 +Revises: 08030acbb158 +Create Date: 2025-05-25 10:25:17.333629 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1a523e61dad7' +down_revision = '08030acbb158' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('company_dev', + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('dev_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['company_id'], ['companies.id'], name=op.f('fk_company_dev_company_id_companies')), + sa.ForeignKeyConstraint(['dev_id'], ['devs.id'], name=op.f('fk_company_dev_dev_id_devs')), + sa.PrimaryKeyConstraint('company_id', 'dev_id') + ) + op.create_table('freebies', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=False), + sa.Column('item_name', sa.String(), nullable=False), + sa.Column('company_id', sa.Integer(), nullable=False), + sa.Column('dev_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['company_id'], ['companies.id'], name=op.f('fk_freebies_company_id_companies')), + sa.ForeignKeyConstraint(['dev_id'], ['devs.id'], name=op.f('fk_freebies_dev_id_devs')), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('freebies') + op.drop_table('company_dev') + # ### end Alembic commands ### diff --git a/migrations/versions/4da5bd63bf9d_add_dev_company_many_to_many_.py b/migrations/versions/4da5bd63bf9d_add_dev_company_many_to_many_.py new file mode 100644 index 000000000..ad6f3260d --- /dev/null +++ b/migrations/versions/4da5bd63bf9d_add_dev_company_many_to_many_.py @@ -0,0 +1,28 @@ +"""Add Dev-Company many-to-many relationship + +Revision ID: 4da5bd63bf9d +Revises: a7479f08fe51 +Create Date: 2025-05-25 11:38:44.137386 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '4da5bd63bf9d' +down_revision = 'a7479f08fe51' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/migrations/versions/__pycache__/08030acbb158_initial_migration.cpython-38.pyc b/migrations/versions/__pycache__/08030acbb158_initial_migration.cpython-38.pyc new file mode 100644 index 000000000..d40a62a4c Binary files /dev/null and b/migrations/versions/__pycache__/08030acbb158_initial_migration.cpython-38.pyc differ diff --git a/migrations/versions/__pycache__/1a523e61dad7_added_a_freebie_and_junction_table.cpython-38.pyc b/migrations/versions/__pycache__/1a523e61dad7_added_a_freebie_and_junction_table.cpython-38.pyc new file mode 100644 index 000000000..ae4485bd9 Binary files /dev/null and b/migrations/versions/__pycache__/1a523e61dad7_added_a_freebie_and_junction_table.cpython-38.pyc differ diff --git a/migrations/versions/__pycache__/4da5bd63bf9d_add_dev_company_many_to_many_.cpython-38.pyc b/migrations/versions/__pycache__/4da5bd63bf9d_add_dev_company_many_to_many_.cpython-38.pyc new file mode 100644 index 000000000..cce893a01 Binary files /dev/null and b/migrations/versions/__pycache__/4da5bd63bf9d_add_dev_company_many_to_many_.cpython-38.pyc differ diff --git a/migrations/versions/__pycache__/a7479f08fe51_removed_title_column_from_freebie.cpython-38.pyc b/migrations/versions/__pycache__/a7479f08fe51_removed_title_column_from_freebie.cpython-38.pyc new file mode 100644 index 000000000..f9666d9b1 Binary files /dev/null and b/migrations/versions/__pycache__/a7479f08fe51_removed_title_column_from_freebie.cpython-38.pyc differ diff --git a/migrations/versions/__pycache__/a9edfab9aa8d_add_dev_company_many_to_many_.cpython-38.pyc b/migrations/versions/__pycache__/a9edfab9aa8d_add_dev_company_many_to_many_.cpython-38.pyc new file mode 100644 index 000000000..d28ccde94 Binary files /dev/null and b/migrations/versions/__pycache__/a9edfab9aa8d_add_dev_company_many_to_many_.cpython-38.pyc differ diff --git a/migrations/versions/a7479f08fe51_removed_title_column_from_freebie.py b/migrations/versions/a7479f08fe51_removed_title_column_from_freebie.py new file mode 100644 index 000000000..db4d5e87b --- /dev/null +++ b/migrations/versions/a7479f08fe51_removed_title_column_from_freebie.py @@ -0,0 +1,34 @@ +"""Removed title column from Freebie + +Revision ID: a7479f08fe51 +Revises: 1a523e61dad7 +Create Date: 2025-05-25 11:21:28.199581 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'a7479f08fe51' +down_revision = '1a523e61dad7' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('freebies', schema=None) as batch_op: + batch_op.add_column(sa.Column('value', sa.Integer(), nullable=False)) + batch_op.drop_column('title') + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('freebies', schema=None) as batch_op: + batch_op.add_column(sa.Column('title', sa.VARCHAR(), nullable=False)) + batch_op.drop_column('value') + + # ### end Alembic commands ### diff --git a/migrations/versions/a9edfab9aa8d_add_dev_company_many_to_many_.py b/migrations/versions/a9edfab9aa8d_add_dev_company_many_to_many_.py new file mode 100644 index 000000000..56e587543 --- /dev/null +++ b/migrations/versions/a9edfab9aa8d_add_dev_company_many_to_many_.py @@ -0,0 +1,28 @@ +"""Add Dev-Company many-to-many relationship + +Revision ID: a9edfab9aa8d +Revises: 4da5bd63bf9d +Create Date: 2025-05-25 11:44:23.634631 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'a9edfab9aa8d' +down_revision = '4da5bd63bf9d' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ###