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

Migration Attributes #46476

Merged
merged 5 commits into from
Jul 30, 2024
Merged

Migration Attributes #46476

merged 5 commits into from
Jul 30, 2024

Conversation

ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Jul 12, 2024

tasks

  • generate metadata from core+available apps (apps are temporary enabled during the process if needed)
  • download file from dl.nc.c
  • extract data and compare with already applied Migrations
  • emulate a generic entry in case a new Attribute is implemented in a future version
  • display data using the occ command
  • making endpoint to display result on the webclient (not done yet, but easily doable as code is now out of Command file)
  • commenting and polishing the code

new occ commands

  • running ./occ migrations:generate-metadata to create a JSON file
  • running ./occ migrations:preview <version> to display migration that will be executed if an upgrade to version is initiated

details

When adding some attributes to a migration:

#[DropTable(table: 'old_table')]
#[CreateTable(table: 'new_table', description: 'Table is used to store things, but also to get more things', notes: ['this is a notice', 'and another one, if really needed'])]
#[AddColumn(table: 'my_table')]
#[AddColumn(table: 'my_table', name: 'another_field')]
#[AddColumn(table: 'other_table', name: 'last_one', type: ColumnType::DATE)]
#[AddIndex(table: 'my_table')]
#[AddIndex(table: 'my_table', type: IndexType::PRIMARY)]
#[DropColumn(table: 'other_table')]
#[DropColumn(table: 'other_table', name: 'old_column', description: 'field is not used anymore and replaced by \'last_one\'')]
#[DropIndex(table: 'other_table')]
#[ModifyColumn(table: 'other_table')]
#[ModifyColumn(table: 'other_table', name: 'this_field')]
#[ModifyColumn(table: 'other_table', name: 'this_field', type: ColumnType::BIGINT)]
class Version30000Date20240102030405 extends SimpleMigrationStep {

will display some details when running the preview occ command:

steps to execute implemented new commands:

when using an install made from repository (with apps/testing/ available):

generate metadata from current install:

./occ migrations:generate-metadata > /tmp/nc.metadata

enable testing app:

./occ app:enable testing

delete migration from db:

DELETE FROM oc_migrations WHERE `oc_migrations`.`app` = 'testing' AND `oc_migrations`.`version` = '30000Date20240102030405'

preview future migrations:

./occ migrations:preview /tmp/nc.metadata     

result:
image

Checklist

@ChristophWurst ChristophWurst added the pending documentation This pull request needs an associated documentation update label Jul 15, 2024
@ChristophWurst
Copy link
Member

  • TableCreation

  • TableDeletion

  • FieldAdd

  • FieldChange

  • FieldRemove

  • IndexAdd

  • IndexRemove

Ease the naming and avoid ambiguity by using standard sql terms

  • CreateTable
  • DeleteTable
  • AddColumn
  • ModifyColumn (consider more specific attributes for type change, rename, etc)
  • DropColumn
  • AddIndex
  • DropIndex

@ArtificialOwl ArtificialOwl marked this pull request as ready for review July 18, 2024 11:33
@ChristophWurst ChristophWurst requested review from a team, Fenn-CS, yemkareems and sorbaugh and removed request for a team July 18, 2024 11:50
@AndyScherzinger AndyScherzinger added this to the Nextcloud 30 milestone Jul 18, 2024
@AndyScherzinger AndyScherzinger linked an issue Jul 18, 2024 that may be closed by this pull request
5 tasks
@ChristophWurst
Copy link
Member

@AndyScherzinger this does not close #45943. It's the first of five changes

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • All new classes, their methods and properties require @since 30.0.0
  • All new classes require unit test coverage

lib/public/Migration/Attributes/DeleteTable.php Outdated Show resolved Hide resolved
lib/public/Migration/Attributes/IndexType.php Outdated Show resolved Hide resolved
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/migration-attributes branch 3 times, most recently from d54eca5 to 9538865 Compare July 26, 2024 17:37
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/migration-attributes branch 2 times, most recently from d9752d9 to 55a5d8e Compare July 29, 2024 12:18
@ArtificialOwl
Copy link
Member Author

psalm error not related: #46846

@ArtificialOwl
Copy link
Member Author

when using an install made from repository (with apps/testing/ available):

generate metadata from current install:

./occ migrations:generate-metadata > /tmp/nc.metadata

enable testing app:

./occ app:enable testing

delete migration from db:

DELETE FROM oc_migrations WHERE `oc_migrations`.`app` = 'testing' AND `oc_migrations`.`version` = '30000Date20240102030405'

preview future migrations:

./occ migrations:preview /tmp/nc.metadata     

result:
image

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>

d

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>

f

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>

d

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jul 29, 2024
@blizzz blizzz mentioned this pull request Jul 30, 2024
@sorbaugh sorbaugh requested a review from Altahrim July 30, 2024 12:53
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attributes look good

@sorbaugh sorbaugh merged commit 18c0bcb into master Jul 30, 2024
169 checks passed
@sorbaugh sorbaugh deleted the enh/noid/migration-attributes branch July 30, 2024 13:54
@ArtificialOwl
Copy link
Member Author

/backport to stable29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement feature: occ pending documentation This pull request needs an associated documentation update 🍂 2024-Autumn
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants